Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public abstract class Process
- Object
- Process
ImplementsAutoCloseable
A child OS process. Stream directions and lifecycle methods follow JavaSE.
Read stdout and stderr concurrently to avoid filling a pipe. Never wait or do
blocking stream I/O on the EDT. Interrupting a wait does not kill the child.
Unlike JavaSE, this class is AutoCloseable: close forcibly terminates the direct
child and closes its three streams. Descendants are not terminated.
Constructors
public Process() |
Methods
Inherited methods
Constructor details
Process
public Process()Method details
getOutputStream
public abstract OutputStream getOutputStream()The child’s stdin (the parent writes to it).
getInputStream
public abstract InputStream getInputStream()The child’s stdout (the parent reads from it).
getErrorStream
public abstract InputStream getErrorStream()The child’s stderr; EOF when redirectErrorStream(true) was selected.
exitValue
public abstract int exitValue()Returns the exit code, or throws IllegalThreadStateException while alive.
destroy
public abstract void destroy()Requests termination of the direct child. On Windows this is forcible.
destroyForcibly
public abstract Process destroyForcibly()Forcibly terminates the direct child; completion is asynchronous.
isAlive
public boolean isAlive()Whether the direct child is still running.
waitFor
public int waitFor()
throws InterruptedExceptionWaits for exit. An interrupt cancels only this wait.
Throws
waitFor
public boolean waitFor(long timeoutMillis)
throws InterruptedExceptionWaits at most timeout milliseconds. Zero/negative values only poll.
Throws
pause
protected void pause(long millis)
throws InterruptedExceptionPort hook for a bounded wait between exit polls.
Throws
waitFor
public boolean waitFor(long timeout, TimeUnit unit)
throws InterruptedExceptionJavaSE-style timed wait; sub-millisecond positive durations round up.
Throws
close
public void close()
throws IOExceptionForcibly terminates the child and releases all pipes, even if one close fails.
The runtime reaps it independently; this does not wait for termination.