Interface WaitableProcessHandle

All Superinterfaces:
Comparable<ProcessHandle>, ProcessHandle

public interface WaitableProcessHandle extends ProcessHandle
A process handle that can be waited for and whose exit value may be read.
  • Method Details

    • command

      Path command()
      Returns the initial process command (not null). This may differ from what ProcessHandle.Info.command() returns.
      Returns:
      the initial process command (not null)
    • arguments

      List<String> arguments()
      Returns the initial process arguments as an immutable list (not null). This may differ from what ProcessHandle.Info.arguments() returns.
      Returns:
      the initial process arguments as an immutable list (not null)
    • waitFor

      int waitFor() throws InterruptedException
      Wait indefinitely for the process to exit.
      Returns:
      the exit code of the process
      Throws:
      InterruptedException - if the current thread is interrupted
      See Also:
    • waitUninterruptiblyFor

      default int waitUninterruptiblyFor()
      Wait indefinitely and uninterruptibly for the process to exit.
      Returns:
      the exit code of the process
      See Also:
    • waitFor

      boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException
      Wait for the process to exit for up to the given time.
      Parameters:
      timeout - the amount of time to wait
      unit - the time unit (must not be null)
      Returns:
      true if the process has exited, or false if it is still running
      Throws:
      InterruptedException - if the current thread is interrupted
      See Also:
    • waitUninterruptiblyFor

      default boolean waitUninterruptiblyFor(long timeout, TimeUnit unit)
      Wait uninterruptibly for the process to exit for up to the given time.
      Parameters:
      timeout - the amount of time to wait
      unit - the time unit (must not be null)
      Returns:
      true if the process has exited, or false if it is still running
      See Also:
    • exitValue

      int exitValue()
      Returns the process exit value.
      Returns:
      the process exit value
      Throws:
      IllegalThreadStateException - if the process has not exited
      See Also: