public class ProcessTree
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ProcessTree.Signal
The constants for the signals.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_SLEEPTIME_BEFORE_SIGKILL |
static boolean |
isSetsidAvailable |
| Constructor and Description |
|---|
ProcessTree() |
| Modifier and Type | Method and Description |
|---|---|
static void |
destroy(java.lang.String pid,
long sleeptimeBeforeSigkill,
boolean isProcessGroup,
boolean inBackground)
Destroy the process-tree.
|
protected static void |
destroyProcess(java.lang.String pid,
long sleeptimeBeforeSigkill,
boolean inBackground)
Destroy the process.
|
protected static void |
destroyProcessGroup(java.lang.String pgrpId,
long sleeptimeBeforeSigkill,
boolean inBackground)
Destroy the process group.
|
static boolean |
isAlive(java.lang.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(java.lang.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(java.lang.String pid,
ProcessTree.Signal signal)
Sends signal to process, forcefully terminating the process.
|
static void |
killProcessGroup(java.lang.String pgrpId,
ProcessTree.Signal signal)
Sends signal to all process belonging to same process group,
forcefully terminating the process group.
|
static void |
terminateProcess(java.lang.String pid)
Sends terminate signal to the process, allowing it to gracefully exit.
|
static void |
terminateProcessGroup(java.lang.String pgrpId)
Sends terminate signal to all the process belonging to the passed process
group, allowing the group to gracefully exit.
|
public static final long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
public static final boolean isSetsidAvailable
public static void destroy(java.lang.String pid,
long sleeptimeBeforeSigkill,
boolean isProcessGroup,
boolean inBackground)
pid - process id of the root process of the subtree of processes
to be killedsleeptimeBeforeSigkill - The time to wait before sending SIGKILL
after sending SIGTERMisProcessGroup - pid is a process group leader or notinBackground - Process is to be killed in the back ground with
a separate threadprotected static void destroyProcess(java.lang.String pid,
long sleeptimeBeforeSigkill,
boolean inBackground)
pid - Process id of to-be-killed-processsleeptimeBeforeSigkill - The time to wait before sending SIGKILL
after sending SIGTERMinBackground - Process is to be killed in the back ground with
a separate threadprotected static void destroyProcessGroup(java.lang.String pgrpId,
long sleeptimeBeforeSigkill,
boolean inBackground)
pgrpId - Process group id of to-be-killed-processessleeptimeBeforeSigkill - The time to wait before sending SIGKILL
after sending SIGTERMinBackground - Process group is to be killed in the back ground with
a separate threadpublic static void terminateProcess(java.lang.String pid)
pid - pid of the process to be sent SIGTERMpublic static void terminateProcessGroup(java.lang.String pgrpId)
pgrpId - process group idpublic static void killProcess(java.lang.String pid,
ProcessTree.Signal signal)
pid - process idsignal - the signal number to sendpublic static void killProcessGroup(java.lang.String pgrpId,
ProcessTree.Signal signal)
pgrpId - process group idsignal - the signal number to sendpublic static boolean isAlive(java.lang.String pid)
pid - pid of the process to check.public static boolean isProcessGroupAlive(java.lang.String pgrpId)
pgrpId - process group idCopyright © 2009 The Apache Software Foundation