Package hudson.util
Class ProcessTree.OSProcess
- java.lang.Object
-
- hudson.util.ProcessTree.OSProcess
-
- All Implemented Interfaces:
ProcessTreeRemoting.IOSProcess
,Serializable
- Direct Known Subclasses:
ProcessTree.UnixProcess
- Enclosing class:
- ProcessTree
public abstract class ProcessTree.OSProcess extends Object implements ProcessTreeRemoting.IOSProcess, Serializable
Represents a process.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> T
act(ProcessTree.ProcessCallable<T> callable)
Executes a chunk of code at the same machine where this process resides.abstract List<String>
getArguments()
Gets the command-line arguments of this process.List<ProcessTree.OSProcess>
getChildren()
Immediate child processes.abstract EnvVars
getEnvironmentVariables()
Obtains the environment variables of this process.abstract ProcessTree.OSProcess
getParent()
Gets the parent process.int
getPid()
protected ProcessKillingVeto.VetoCause
getVeto()
boolean
hasMatchingEnvVars(Map<String,String> modelEnvVar)
Given the environment variable of a process and the "model environment variable" that Hudson used for launching the build, returns true if there's a match (which means the process should be considered a descendant of a build.)abstract void
kill()
Kills this process.abstract void
killRecursively()
Kills this process and all the descendants.
-
-
-
Method Detail
-
getPid
public final int getPid()
- Specified by:
getPid
in interfaceProcessTreeRemoting.IOSProcess
-
getParent
@CheckForNull public abstract ProcessTree.OSProcess getParent()
Gets the parent process. This method may return null, because there's no guarantee that we are getting a consistent snapshot of the whole system state.- Specified by:
getParent
in interfaceProcessTreeRemoting.IOSProcess
-
getChildren
@NonNull public final List<ProcessTree.OSProcess> getChildren()
Immediate child processes.
-
kill
public abstract void kill() throws InterruptedException
Kills this process.- Specified by:
kill
in interfaceProcessTreeRemoting.IOSProcess
- Throws:
InterruptedException
-
killRecursively
public abstract void killRecursively() throws InterruptedException
Kills this process and all the descendants.Note that the notion of "descendants" is somewhat vague, in the presence of such things like daemons. On platforms where the recursive operation is not supported, this just kills the current process.
- Specified by:
killRecursively
in interfaceProcessTreeRemoting.IOSProcess
- Throws:
InterruptedException
-
getVeto
@CheckForNull protected ProcessKillingVeto.VetoCause getVeto()
- Returns:
- The first non-null
ProcessKillingVeto.VetoCause
provided by a process killing veto extension for this OSProcess. null if no one objects killing the process.
-
getArguments
@NonNull public abstract List<String> getArguments()
Gets the command-line arguments of this process.On Windows, where the OS models command-line arguments as a single string, this method computes the approximated tokenization.
- Specified by:
getArguments
in interfaceProcessTreeRemoting.IOSProcess
-
getEnvironmentVariables
@NonNull public abstract EnvVars getEnvironmentVariables()
Obtains the environment variables of this process.- Specified by:
getEnvironmentVariables
in interfaceProcessTreeRemoting.IOSProcess
- Returns:
- empty map if failed (for example because the process is already dead, or the permission was denied.)
-
hasMatchingEnvVars
public final boolean hasMatchingEnvVars(Map<String,String> modelEnvVar)
Given the environment variable of a process and the "model environment variable" that Hudson used for launching the build, returns true if there's a match (which means the process should be considered a descendant of a build.)
-
act
public <T> T act(ProcessTree.ProcessCallable<T> callable) throws IOException, InterruptedException
Executes a chunk of code at the same machine where this process resides.- Specified by:
act
in interfaceProcessTreeRemoting.IOSProcess
- Throws:
IOException
InterruptedException
-
-