Class ProcessTree
- java.lang.Object
-
- org.ow2.proactive.process_tree_killer.ProcessTree
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<ProcessTree.OSProcess>,ProcessTreeRemoting.IProcessTree
- Direct Known Subclasses:
ProcessTree.Local
public abstract class ProcessTree extends java.lang.Object implements java.lang.Iterable<ProcessTree.OSProcess>, ProcessTreeRemoting.IProcessTree, java.io.Serializable
Represents a snapshot of the process tree of the current system.A
ProcessTreeis really conceptually a map from process ID to aProcessTree.OSProcessobject. When Hudson runs on platforms that support process introspection, this allows you to introspect and do some useful things on processes. On other platforms, the implementation falls back to "do nothing" behavior.ProcessTreeis remotable.- Since:
- 1.315
- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProcessTree.LocalRepresents a local process tree, where this JVM and the process tree run on the same system.classProcessTree.OSProcessRepresents a process.classProcessTree.UnixProcessA process.
-
Field Summary
Fields Modifier and Type Field Description static booleanenabledFlag to control this feature.protected java.util.Map<java.lang.Integer,ProcessTree.OSProcess>processesTo be filled in the constructor of the derived type.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ProcessTreeget()Gets theProcessTreeof the current system that JVM runs in, or in the worst case return the default one that's not capable of killing descendants at all.ProcessTree.OSProcessget(int pid)Gets the process given a specific ID, or null if no such process exists.abstract ProcessTree.OSProcessget(java.lang.Process proc)Try to convertProcessinto this process object or null if it fails (for example, maybe the snapshot is taken after this process has already finished.)java.util.Iterator<ProcessTree.OSProcess>iterator()Lists all the processes in the system.voidkillAll(java.lang.Process proc, java.util.Map<java.lang.String,java.lang.String> modelEnvVars)Convenience method that doeskillAll(Map)andProcessTree.OSProcess.killRecursively().abstract voidkillAll(java.util.Map<java.lang.String,java.lang.String> modelEnvVars)Kills all the processes that have matching environment variables.
-
-
-
Field Detail
-
processes
protected final java.util.Map<java.lang.Integer,ProcessTree.OSProcess> processes
To be filled in the constructor of the derived type.
-
enabled
public static boolean enabled
Flag to control this feature.This feature involves some native code, so we are allowing the user to disable this in case there's a fatal problem.
This property supports two names for a compatibility reason.
-
-
Method Detail
-
get
public final ProcessTree.OSProcess get(int pid)
Gets the process given a specific ID, or null if no such process exists.
-
iterator
public final java.util.Iterator<ProcessTree.OSProcess> iterator()
Lists all the processes in the system.- Specified by:
iteratorin interfacejava.lang.Iterable<ProcessTree.OSProcess>
-
get
public abstract ProcessTree.OSProcess get(java.lang.Process proc)
Try to convertProcessinto this process object or null if it fails (for example, maybe the snapshot is taken after this process has already finished.)
-
killAll
public abstract void killAll(java.util.Map<java.lang.String,java.lang.String> modelEnvVars) throws java.lang.InterruptedExceptionKills all the processes that have matching environment variables.In this method, the method is given a "model environment variables", which is a list of environment variables and their values that are characteristic to the launched process. The implementation is expected to find processes in the system that inherit these environment variables, and kill them all. This is suitable for locating daemon processes that cannot be tracked by the regular ancestor/descendant relationship.
- Specified by:
killAllin interfaceProcessTreeRemoting.IProcessTree- Throws:
java.lang.InterruptedException
-
killAll
public void killAll(java.lang.Process proc, java.util.Map<java.lang.String,java.lang.String> modelEnvVars) throws java.lang.InterruptedExceptionConvenience method that doeskillAll(Map)andProcessTree.OSProcess.killRecursively(). This is necessary to reliably kill the process and its descendants, as some OS may not implementkillAll(Map). Either of the parameter can be null.- Throws:
java.lang.InterruptedException
-
get
public static ProcessTree get()
Gets theProcessTreeof the current system that JVM runs in, or in the worst case return the default one that's not capable of killing descendants at all.
-
-