Class UnixProcess

All Implemented Interfaces:
SystemProcess

public class UnixProcess extends PidProcess
Process implementation for UNIX PID values.

It uses the getpgid system call for checking the status and the kill one for destroying the process.

  • Constructor Details

    • UnixProcess

      public UnixProcess(int pid)
  • Method Details

    • isAlive

      public boolean isAlive() throws IOException
      Description copied from interface: SystemProcess
      Tests whether this process is alive.

      This operation may take some time to finish.

      Returns:
      true if this process is alive, false if it is finished or not found.
      Throws:
      IOException - on IO error.
    • destroy

      public void destroy(boolean forceful) throws IOException
      Description copied from class: AbstractProcess
      Destroys the process either forcefully or gracefully according to the given option.

      Note: The process may not terminate at all. i.e. isAlive() may return true for a any period after destroy() is called. This method may be chained to waitFor() if needed.

      No error is thrown if the process was already terminated.

      Specified by:
      destroy in class AbstractProcess
      Parameters:
      forceful - true if the process must be destroyed forcefully (like kill -KILL), false if it must be destroyed gracefully (like kill -TERM).
      Throws:
      IOException - on IO error.
    • kill

      public boolean kill(int signal) throws IOException
      Sends a signal to this process.
      Parameters:
      signal - name of the signal.
      Returns:
      true if this process received the signal, false if this process was not found (any more).
      Throws:
      IOException - on system call error.