@InterfaceAudience.Private @InterfaceStability.Unstable public class ProcessTree extends Object
| 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(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 |
sigQuitProcess(String pid)
Sends SIGQUIT to process; Java programs will dump their stack to
stdout.
|
static void |
sigQuitProcessGroup(String pgrpId)
Sends SIGQUIT to all processes belonging to the same process group,
ordering all processes in the group to send their stack dump to
stdout.
|
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.
|
public static final long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
public static final boolean isSetsidAvailable
public static void destroy(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(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(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(String pid)
pid - pid of the process to be sent SIGTERMpublic static void terminateProcessGroup(String pgrpId)
pgrpId - process group idpublic static void killProcess(String pid)
pid - process idpublic static void sigQuitProcess(String pid)
pid - process idpublic static void killProcessGroup(String pgrpId)
pgrpId - process group idpublic static void sigQuitProcessGroup(String pgrpId)
pgrpId - process group idpublic static boolean isAlive(String pid)
pid - pid of the process to check.public static boolean isProcessGroupAlive(String pgrpId)
pgrpId - process group idCopyright © 2022 Apache Software Foundation. All rights reserved.