Class Process

java.lang.Object
jnr.process.Process

public class Process extends Object
A Process look-alike based on the Java Native Runtime's native FFI binding. Note this adds the getIn(), getOut(), and getErr() methods for accessing selectable channels from the child process, as well as killProcessGroup() to kill the child and descendants.
  • Method Details

    • getPid

      public long getPid()
      Get the pid of the child process.
      Returns:
      the pid of the child process
    • getOut

      public SelectableChannel getOut()
      Get the selectable channel for the parent's output, which is the child's input.
      Returns:
      the parent's output channel for the child's input
    • getOutputStream

      public OutputStream getOutputStream()
      Get the stream for the parent's output, which is the child's input.
      Returns:
      the parent's output stream for the child's input
    • getIn

      public SelectableChannel getIn()
      Get the selectable channel for the parent's input, which is the child's output.
      Returns:
      the parent's input channel for the child's output
    • getInputStream

      public InputStream getInputStream()
      Get the stream for the parent's input, which is the child's output.
      Returns:
      the parent's input stream for the child's output
    • getErr

      public SelectableChannel getErr()
      Get the selectable channel for the error stream (input for parent, error output for child).
      Returns:
      the parent's error input channel for the child's error output
    • getErrorStream

      public InputStream getErrorStream()
      Get the stream for the error stream (input for parent, error output for child).
      Returns:
      the parent's error input stream for the child's error output
    • waitFor

      public long waitFor()
      Wait for the subprocess to terminate and return its exit code.
      Returns:
      the exit code from the child process, after it has terminated
    • kill

      public int kill()
      Kill the child process with a KILL signal.
      Returns:
      the return code from the native kill function
    • kill

      public int kill(jnr.constants.platform.Signal sig)
      Kill the child process with the specified signal.
      Parameters:
      sig - the signal to send to the child process
      Returns:
      the return code from the native kill function
    • killProcessGroup

      public int killProcessGroup()
      Kill the child process and all its descendants with a KILL signal.
      Returns:
      the return code from the native kill function
    • killProcessGroup

      public int killProcessGroup(jnr.constants.platform.Signal sig)
      Kill the child process and all its descendants with the specified signal.
      Parameters:
      sig - the signal to send to the child and its descendants
      Returns:
      the return code from the native kill function
    • exitValue

      public long exitValue()
      Get the exit code from the child process, or raise IllegalThreadStateException if it has not yet terminated.
      Returns:
      the exit value from the terminated child process