hudson.util
Class ProcessKiller

java.lang.Object
  extended by hudson.util.ProcessKiller
All Implemented Interfaces:
ExtensionPoint, Serializable

public abstract class ProcessKiller
extends Object
implements ExtensionPoint, Serializable

Extension point that defines more elaborate way of killing processes, such as sudo or pfexec, for ProcessTree.

Lifecycle

Each implementation of ProcessKiller is instantiated once on the master. Whenever a process needs to be killed, those implementations are serialized and sent over to the appropriate slave, then the #kill(OSProcess) method is invoked to attempt to kill the process.

One of the consequences of this design is that the implementation should be stateless and concurrent-safe. That is, the #kill(OSProcess) method can be invoked by multiple threads concurrently on the single instance.

Another consequence of this design is that if your ProcessKiller requires configuration, it needs to be serializable, and configuration needs to be updated atomically, as another thread may be calling into #kill(OSProcess) just when you are updating your configuration.

Since:
1.362
Author:
jpederzolli, Kohsuke Kawaguchi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
ProcessKiller()
           
 
Method Summary
static ExtensionList<ProcessKiller> all()
          Returns all the registered ProcessKiller descriptors.
abstract  boolean kill(ProcessTree.OSProcess process)
          Attempts to kill the given process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessKiller

public ProcessKiller()
Method Detail

all

public static ExtensionList<ProcessKiller> all()
Returns all the registered ProcessKiller descriptors.


kill

public abstract boolean kill(ProcessTree.OSProcess process)
                      throws IOException,
                             InterruptedException
Attempts to kill the given process.

Parameters:
process - process to be killed. Always a local process.
Returns:
true if the killing was successful, and Hudson won't try to use other ProcessKiller implementations to kill the process. false if the killing failed or is unattempted, and Hudson will continue to use the rest of the ProcessKiller implementations to try to kill the process.
Throws:
IOException - The caller will log this exception and otherwise treat as if the method returned false, and moves on to the next killer.
InterruptedException - if the callee performs a time consuming operation and if the thread is canceled, do not catch InterruptedException and just let it thrown from the method.


Copyright © 2004-2013. All Rights Reserved.