Package hudson
Class Proc
java.lang.Object
hudson.Proc
- Direct Known Subclasses:
Launcher.RemoteLauncher.ProcImpl
,Proc.LocalProc
,Proc.RemoteProc
External process wrapper.
Used for launching, monitoring, waiting for a process.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Locally launched process.static interface
An instance ofProc
, which has an internal workaround for JENKINS-23271.static final class
Deprecated.as of 1.399. -
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Debug switch to have the thread display the process it's waiting for. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract InputStream
Returns anInputStream
to read fromstderr
of the child process.abstract OutputStream
getStdin()
Returns anOutputStream
to write tostdin
of the child process.abstract InputStream
Returns anInputStream
to read fromstdout
of the child process.abstract boolean
isAlive()
Checks if the process is still alive.abstract int
join()
Waits for the completion of the process.final int
joinWithTimeout
(long timeout, TimeUnit unit, TaskListener listener) Likejoin()
but can be given a maximum time to wait.abstract void
kill()
Terminates the process.
-
Field Details
-
SHOW_PID
public static boolean SHOW_PIDDebug switch to have the thread display the process it's waiting for.
-
-
Constructor Details
-
Proc
protected Proc()
-
-
Method Details
-
isAlive
Checks if the process is still alive.- Throws:
IOException
InterruptedException
-
kill
Terminates the process.- Throws:
IOException
- if there's an error killing a process and a stack trace could help the trouble-shooting.InterruptedException
-
join
Waits for the completion of the process. Unless the caller opts to pump the streams viagetStdout()
etc., this method also blocks until we finish reading everything that the process has produced to stdout/stderr.If the thread is interrupted while waiting for the completion of the process, this method terminates the process and exits with a non-zero exit code.
- Throws:
IOException
- if there's an error launching/joining a process and a stack trace could help the trouble-shooting.InterruptedException
-
getStdout
Returns anInputStream
to read fromstdout
of the child process.When this method returns null,
Proc
will internally pump the output from the child process to yourOutputStream
of choosing.- Returns:
null
unlessLauncher.ProcStarter.readStdout()
is used to indicate that the caller intends to pump the stream by itself.- Since:
- 1.399
-
getStderr
Returns anInputStream
to read fromstderr
of the child process.When this method returns null,
Proc
will internally pump the output from the child process to yourOutputStream
of choosing.- Returns:
null
unlessLauncher.ProcStarter.readStderr()
is used to indicate that the caller intends to pump the stream by itself.- Since:
- 1.399
-
getStdin
Returns anOutputStream
to write tostdin
of the child process.When this method returns null,
Proc
will internally pump theInputStream
of your choosing to the child process.- Returns:
null
unlessLauncher.ProcStarter.writeStdin()
is used to indicate that the caller intends to pump the stream by itself.- Since:
- 1.399
-
joinWithTimeout
public final int joinWithTimeout(long timeout, TimeUnit unit, TaskListener listener) throws IOException, InterruptedException Likejoin()
but can be given a maximum time to wait.- Parameters:
timeout
- number of time unitsunit
- unit of timelistener
- place to send messages if there are problems, incl. timeout- Returns:
- exit code from the process
- Throws:
IOException
- for the same reasons asjoin()
InterruptedException
- for the same reasons asjoin()
- Since:
- 1.363
-