hudson
Class Proc

java.lang.Object
  extended by hudson.Proc
Direct Known Subclasses:
FakeLauncher.FinishedProc, Launcher.RemoteLauncher.ProcImpl, Proc.LocalProc, Proc.RemoteProc

public abstract class Proc
extends Object

External process wrapper.

Used for launching, monitoring, waiting for a process.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class Proc.LocalProc
          Locally launched process.
static class Proc.RemoteProc
          Deprecated. as of 1.399. Replaced by Launcher.RemoteLauncher.ProcImpl
 
Field Summary
static boolean SHOW_PID
          Debug switch to have the thread display the process it's waiting for.
 
Constructor Summary
protected Proc()
           
 
Method Summary
abstract  InputStream getStderr()
          Returns an InputStream to read from stderr of the child process.
abstract  OutputStream getStdin()
          Returns an OutputStream to write to stdin of the child process.
abstract  InputStream getStdout()
          Returns an InputStream to read from stdout of the child process.
abstract  boolean isAlive()
          Checks if the process is still alive.
abstract  int join()
          Waits for the completion of the process.
 int joinWithTimeout(long timeout, TimeUnit unit, TaskListener listener)
          Like join() but can be given a maximum time to wait.
abstract  void kill()
          Terminates the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_PID

public static boolean SHOW_PID
Debug switch to have the thread display the process it's waiting for.

Constructor Detail

Proc

protected Proc()
Method Detail

isAlive

public abstract boolean isAlive()
                         throws IOException,
                                InterruptedException
Checks if the process is still alive.

Throws:
IOException
InterruptedException

kill

public abstract void kill()
                   throws IOException,
                          InterruptedException
Terminates the process.

Throws:
IOException - if there's an error killing a process and a stack trace could help the trouble-shooting.
InterruptedException

join

public abstract int join()
                  throws IOException,
                         InterruptedException
Waits for the completion of the process. Unless the caller opts to pump the streams via getStdout() 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

public abstract InputStream getStdout()
Returns an InputStream to read from stdout of the child process.

When this method returns null, Proc.LocalProc will internally pump the output from the child process to your OutputStream of choosing.

Returns:
null unless Launcher.ProcStarter.readStdout() is used to indicate that the caller intends to pump the stream by itself.
Since:
1.399

getStderr

public abstract InputStream getStderr()
Returns an InputStream to read from stderr of the child process.

When this method returns null, Proc.LocalProc will internally pump the output from the child process to your OutputStream of choosing.

Returns:
null unless Launcher.ProcStarter.readStderr() is used to indicate that the caller intends to pump the stream by itself.
Since:
1.399

getStdin

public abstract OutputStream getStdin()
Returns an OutputStream to write to stdin of the child process.

When this method returns null, Proc.LocalProc will internally pump the InputStream of your choosing to the child process.

Returns:
null unless Launcher.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
Like join() 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


Copyright © 2004-2013. All Rights Reserved.