Package gov.usgs.util
Class TimeoutProcess
- java.lang.Object
-
- gov.usgs.util.TimeoutProcess
-
public class TimeoutProcess extends java.lang.Object
TimeoutProcess wraps a Process object. It is most commonly used with TimeoutProcessBuilder, which configures the process timeout (and sets the timed out state once the timeout is reached).- See Also:
Process
,TimeoutProcessBuilder
,ProcessTimeoutException
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TimeoutProcess(java.lang.Process process)
Construct a new TimeoutProcess.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroys a processbyte[]
errorOutput()
int
exitValue()
java.io.InputStream
getErrorStream()
java.io.InputStream
getInputStream()
java.io.OutputStream
getOutputStream()
protected void
setTimeoutElapsed(boolean timeoutElapsed)
protected void
setTimer(java.util.Timer timer)
protected boolean
timeoutElapsed()
int
waitFor()
Wait for the process to complete, either normally or because its timeout was reached.
-
-
-
Method Detail
-
destroy
public void destroy()
Destroys a process
-
errorOutput
public byte[] errorOutput()
- Returns:
- errorOutput byte array
-
exitValue
public int exitValue()
- Returns:
- exit value
-
getErrorStream
public java.io.InputStream getErrorStream()
- Returns:
- InputStream of error stream
-
getInputStream
public java.io.InputStream getInputStream()
- Returns:
- InputStream
-
getOutputStream
public java.io.OutputStream getOutputStream()
- Returns:
- OutputStream
-
waitFor
public int waitFor() throws java.lang.InterruptedException, java.io.IOException, ProcessTimeoutException
Wait for the process to complete, either normally or because its timeout was reached.- Returns:
- exitStatus.
- Throws:
java.lang.InterruptedException
- if thread interruption occursjava.io.IOException
- if IO error occursProcessTimeoutException
- if the process timed out before exiting.
-
setTimeoutElapsed
protected void setTimeoutElapsed(boolean timeoutElapsed)
- Parameters:
timeoutElapsed
- to set
-
timeoutElapsed
protected boolean timeoutElapsed()
- Returns:
- timeoutElapsed boolean
-
setTimer
protected void setTimer(java.util.Timer timer)
- Parameters:
timer
- to set
-
-