Class Process
java.lang.Object
com.codename1.io.Process
- All Implemented Interfaces:
AutoCloseable
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Forcibly terminates the child and releases all pipes, even if one close fails.abstract voiddestroy()Requests termination of the direct child.abstract ProcessForcibly terminates the direct child; completion is asynchronous.abstract intReturns the exit code, or throws IllegalThreadStateException while alive.abstract InputStreamThe child's stderr; EOF when redirectErrorStream(true) was selected.abstract InputStreamThe child's stdout (the parent reads from it).abstract OutputStreamThe child's stdin (the parent writes to it).booleanisAlive()Whether the direct child is still running.protected voidpause(long millis) Port hook for a bounded wait between exit polls.intwaitFor()Waits for exit.booleanwaitFor(long timeoutMillis) Waits at most timeout milliseconds.booleanJavaSE-style timed wait; sub-millisecond positive durations round up.
-
Constructor Details
-
Process
public Process()
-
-
Method Details
-
getOutputStream
The child's stdin (the parent writes to it). -
getInputStream
The child's stdout (the parent reads from it). -
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
Forcibly terminates the direct child; completion is asynchronous. -
isAlive
public boolean isAlive()Whether the direct child is still running. -
waitFor
Waits for exit. An interrupt cancels only this wait.- Throws:
InterruptedException
-
waitFor
Waits at most timeout milliseconds. Zero/negative values only poll.- Throws:
InterruptedException
-
pause
Port hook for a bounded wait between exit polls.- Throws:
InterruptedException
-
waitFor
JavaSE-style timed wait; sub-millisecond positive durations round up.- Throws:
InterruptedException
-
close
Forcibly terminates the child and releases all pipes, even if one close fails. The runtime reaps it independently; this does not wait for termination.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-