net.groboclown.util.thread.v1
Class BackgroundProcess
java.lang.Object
|
+--net.groboclown.util.thread.v1.BackgroundProcess
- public class BackgroundProcess
- extends Object
Creates and executes the given process. Ensures that all the output
is properly read without overflowing or dead-locking the process.
Outside of the streaming, this class has an identical API to that
of Process
.
Creation of a background process begins at the creation of this object.
Changes for 0.9.1d
- Each IOThreadRunner which handles the background process's
IO have been changed such that they now close the streams when
an EOL is encountered, and have no delay between reads.
- Since:
- 0.9.1b
- Version:
- 0.9.1d
- Author:
- Matt Albrecht
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
proc
private Process proc
stdIn
private OutputStream stdIn
outReader
private PipedInputStream outReader
outWriter
private PipedOutputStream outWriter
errReader
private PipedInputStream errReader
errWriter
private PipedOutputStream errWriter
outThread
private IOThreadRunner outThread
errThread
private IOThreadRunner errThread
BackgroundProcess
public BackgroundProcess(String command)
throws IOException
- See Also:
java.lang.Runtime#exec( String )
BackgroundProcess
public BackgroundProcess(String[] cmdarray)
throws IOException
- See Also:
java.lang.Runtime#exec( String[] )
BackgroundProcess
public BackgroundProcess(String[] cmdarray,
String[] envp,
File dir)
throws IOException
- See Also:
java.lang.Runtime#exec( String[], String[], File )
BackgroundProcess
public BackgroundProcess(String command,
String[] envp,
File dir)
throws IOException
- See Also:
java.lang.Runtime#exec( String, String[], File )
BackgroundProcess
public BackgroundProcess(String[] cmdarray,
String[] envp)
throws IOException
- See Also:
java.lang.Runtime#exec( String[], String[] )
BackgroundProcess
public BackgroundProcess(String command,
String[] envp)
throws IOException
- See Also:
java.lang.Runtime#exec( String, String[] )
BackgroundProcess
public BackgroundProcess(Process p)
throws IOException
- Initializes the background process with an existing process.
getStdIn
public OutputStream getStdIn()
- Get the OutputStream that is sent to the StdIn of the process.
getStdOut
public InputStream getStdOut()
- Get the InputStream that retrieves the data from the StdOut of the
process.
getStdErr
public InputStream getStdErr()
- Get the InputStream that retrieves the data from the StdErr of the
process.
destroy
public void destroy()
- See Also:
Process.destroy()
exitValue
public int exitValue()
- See Also:
Process.exitValue()
waitFor
public int waitFor()
throws InterruptedException
- See Also:
Process.waitFor()
setupProcess
protected void setupProcess(Process p)
throws IOException
- Initalize the process for internal use.
Written under the LGPL