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 SummaryNested ClassesModifier and TypeClassDescriptionstatic final classLocally launched process.static interfaceAn instance ofProc, which has an internal workaround for JENKINS-23271.static final classDeprecated.as of 1.399.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic booleanDebug switch to have the thread display the process it's waiting for.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract InputStreamReturns anInputStreamto read fromstderrof the child process.abstract OutputStreamgetStdin()Returns anOutputStreamto write tostdinof the child process.abstract InputStreamReturns anInputStreamto read fromstdoutof the child process.abstract booleanisAlive()Checks if the process is still alive.abstract intjoin()Waits for the completion of the process.final intjoinWithTimeout(long timeout, TimeUnit unit, TaskListener listener) Likejoin()but can be given a maximum time to wait.abstract voidkill()Terminates the process.
- 
Field Details- 
SHOW_PIDpublic static boolean SHOW_PIDDebug switch to have the thread display the process it's waiting for.
 
- 
- 
Constructor Details- 
Procprotected Proc()
 
- 
- 
Method Details- 
isAliveChecks if the process is still alive.- Throws:
- IOException
- InterruptedException
 
- 
killTerminates the process.- Throws:
- IOException- if there's an error killing a process and a stack trace could help the trouble-shooting.
- InterruptedException
 
- 
joinWaits 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
 
- 
getStdoutReturns anInputStreamto read fromstdoutof the child process.When this method returns null, Procwill internally pump the output from the child process to yourOutputStreamof choosing.- Returns:
- nullunless- Launcher.ProcStarter.readStdout()is used to indicate that the caller intends to pump the stream by itself.
- Since:
- 1.399
 
- 
getStderrReturns anInputStreamto read fromstderrof the child process.When this method returns null, Procwill internally pump the output from the child process to yourOutputStreamof choosing.- Returns:
- nullunless- Launcher.ProcStarter.readStderr()is used to indicate that the caller intends to pump the stream by itself.
- Since:
- 1.399
 
- 
getStdinReturns anOutputStreamto write tostdinof the child process.When this method returns null, Procwill internally pump theInputStreamof your choosing to the child process.- Returns:
- nullunless- Launcher.ProcStarter.writeStdin()is used to indicate that the caller intends to pump the stream by itself.
- Since:
- 1.399
 
- 
joinWithTimeoutpublic 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 units
- unit- unit of time
- listener- place to send messages if there are problems, incl. timeout
- Returns:
- exit code from the process
- Throws:
- IOException- for the same reasons as- join()
- InterruptedException- for the same reasons as- join()
- Since:
- 1.363
 
 
-