org.apache.hadoop.util
Class ProcessTree

java.lang.Object
  extended by org.apache.hadoop.util.ProcessTree
Direct Known Subclasses:
ProcfsBasedProcessTree

public class ProcessTree
extends Object

Process tree related operations


Field Summary
static long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
           
static boolean isSetsidAvailable
           
 
Constructor Summary
ProcessTree()
           
 
Method Summary
static void destroy(String pid, long sleeptimeBeforeSigkill, boolean isProcessGroup, boolean inBackground)
          Destroy the process-tree.
protected static void destroyProcess(String pid, long sleeptimeBeforeSigkill, boolean inBackground)
          Destroy the process.
protected static void destroyProcessGroup(String pgrpId, long sleeptimeBeforeSigkill, boolean inBackground)
          Destroy the process group.
static boolean isAlive(String pid)
          Is the process with PID pid still alive? This method assumes that isAlive is called on a pid that was alive not too long ago, and hence assumes no chance of pid-wrapping-around.
static boolean isProcessGroupAlive(String pgrpId)
          Is the process group with still alive? This method assumes that isAlive is called on a pid that was alive not too long ago, and hence assumes no chance of pid-wrapping-around.
static void killProcess(String pid)
          Sends kill signal to process, forcefully terminating the process.
static void killProcessGroup(String pgrpId)
          Sends kill signal to all process belonging to same process group, forcefully terminating the process group.
static void terminateProcess(String pid)
          Sends terminate signal to the process, allowing it to gracefully exit.
static void terminateProcessGroup(String pgrpId)
          Sends terminate signal to all the process belonging to the passed process group, allowing the group to gracefully exit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SLEEPTIME_BEFORE_SIGKILL

public static final long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
See Also:
Constant Field Values

isSetsidAvailable

public static final boolean isSetsidAvailable
Constructor Detail

ProcessTree

public ProcessTree()
Method Detail

destroy

public static void destroy(String pid,
                           long sleeptimeBeforeSigkill,
                           boolean isProcessGroup,
                           boolean inBackground)
Destroy the process-tree.

Parameters:
pid - process id of the root process of the subtree of processes to be killed
sleeptimeBeforeSigkill - The time to wait before sending SIGKILL after sending SIGTERM
isProcessGroup - pid is a process group leader or not
inBackground - Process is to be killed in the back ground with a separate thread

destroyProcess

protected static void destroyProcess(String pid,
                                     long sleeptimeBeforeSigkill,
                                     boolean inBackground)
Destroy the process.

Parameters:
pid - Process id of to-be-killed-process
sleeptimeBeforeSigkill - The time to wait before sending SIGKILL after sending SIGTERM
inBackground - Process is to be killed in the back ground with a separate thread

destroyProcessGroup

protected static void destroyProcessGroup(String pgrpId,
                                          long sleeptimeBeforeSigkill,
                                          boolean inBackground)
Destroy the process group.

Parameters:
pgrpId - Process group id of to-be-killed-processes
sleeptimeBeforeSigkill - The time to wait before sending SIGKILL after sending SIGTERM
inBackground - Process group is to be killed in the back ground with a separate thread

terminateProcess

public static void terminateProcess(String pid)
Sends terminate signal to the process, allowing it to gracefully exit.

Parameters:
pid - pid of the process to be sent SIGTERM

terminateProcessGroup

public static void terminateProcessGroup(String pgrpId)
Sends terminate signal to all the process belonging to the passed process group, allowing the group to gracefully exit.

Parameters:
pgrpId - process group id

killProcess

public static void killProcess(String pid)
Sends kill signal to process, forcefully terminating the process.

Parameters:
pid - process id

killProcessGroup

public static void killProcessGroup(String pgrpId)
Sends kill signal to all process belonging to same process group, forcefully terminating the process group.

Parameters:
pgrpId - process group id

isAlive

public static boolean isAlive(String pid)
Is the process with PID pid still alive? This method assumes that isAlive is called on a pid that was alive not too long ago, and hence assumes no chance of pid-wrapping-around.

Parameters:
pid - pid of the process to check.
Returns:
true if process is alive.

isProcessGroupAlive

public static boolean isProcessGroupAlive(String pgrpId)
Is the process group with still alive? This method assumes that isAlive is called on a pid that was alive not too long ago, and hence assumes no chance of pid-wrapping-around.

Parameters:
pgrpId - process group id
Returns:
true if any of process in group is alive.


Copyright © 2009 The Apache Software Foundation