Class ProcessTree
- All Implemented Interfaces:
ProcessTreeRemoting.IProcessTree,Serializable,Iterable<ProcessTree.OSProcess>,org.jenkinsci.remoting.SerializableOnlyOverRemoting
- Direct Known Subclasses:
ProcessTree.Local,ProcessTree.Remote
A ProcessTree is really conceptually a map from process ID to a ProcessTree.OSProcess object.
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.
ProcessTree is remotable.
- Since:
- 1.315
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a local process tree, where this JVM and the process tree run on the same system.classRepresents a process.static interfaceCode that gets executed on the machine where theProcessTree.OSProcessis local.static classRepresents a process tree over a channel.classA process. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<Integer,ProcessTree.OSProcess> To be filled in the constructor of the derived type. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.final ProcessTree.OSProcessget(int pid) Gets the process given a specific ID, or null if no such process exists.abstract ProcessTree.OSProcessTry to convertProcessinto this process object or null if it fails (for example, maybe the snapshot is taken after this process has already finished.)final Iterator<ProcessTree.OSProcess>iterator()Lists all the processes in the system.voidConvenience method that doeskillAll(Map)andProcessTree.OSProcess.killRecursively().abstract voidKills all the processes that have matching environment variables.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jenkinsci.remoting.SerializableOnlyOverRemoting
getChannelForSerialization
-
Field Details
-
processes
To be filled in the constructor of the derived type.
-
-
Method Details
-
get
Gets the process given a specific ID, or null if no such process exists. -
iterator
Lists all the processes in the system.- Specified by:
iteratorin interfaceIterable<ProcessTree.OSProcess>
-
get
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
Kills 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:
InterruptedException
-
killAll
public void killAll(@CheckForNull Process proc, @CheckForNull Map<String, String> modelEnvVars) throws 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:
InterruptedException
-
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.
-