org.zeroturnaround.process
Class UnixProcess

java.lang.Object
  extended by org.zeroturnaround.process.AbstractProcess
      extended by org.zeroturnaround.process.PollingProcess
          extended by org.zeroturnaround.process.PidProcess
              extended by org.zeroturnaround.process.UnixProcess
All Implemented Interfaces:
SystemProcess
Direct Known Subclasses:
SolarisProcess

public class UnixProcess
extends PidProcess

Process implementation for UNIX PID values.

It uses the kill command for both checking the status and destroying the process.


Field Summary
 
Fields inherited from class org.zeroturnaround.process.PidProcess
pid
 
Fields inherited from class org.zeroturnaround.process.AbstractProcess
log
 
Constructor Summary
UnixProcess(int pid)
           
 
Method Summary
 void destroy(boolean forceful)
          Destroys the process handled by this killer either forcefully or gracefully according to the given option.
 boolean isAlive()
          Tests whether this process is alive.
protected  boolean isNoSuchProcess(org.zeroturnaround.exec.InvalidExitValueException e)
           
 boolean kill(String signal)
          Sends a signal to this process.
 
Methods inherited from class org.zeroturnaround.process.PidProcess
getDescription, getPid
 
Methods inherited from class org.zeroturnaround.process.PollingProcess
getIntervalForCheckingFinished, setIntervalForCheckingFinished, waitFor
 
Methods inherited from class org.zeroturnaround.process.AbstractProcess
destroyForcefully, destroyGracefully, toString, waitFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnixProcess

public UnixProcess(int pid)
Method Detail

isAlive

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

This operation may also take some time to finish.

Returns:
true if this process is alive, false if it is finished or not found.
Throws:
IOException
InterruptedException

destroy

public void destroy(boolean forceful)
             throws IOException,
                    InterruptedException
Description copied from class: AbstractProcess
Destroys the process handled by this killer 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
InterruptedException

kill

public boolean kill(String signal)
             throws IOException,
                    InterruptedException
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
InterruptedException

isNoSuchProcess

protected boolean isNoSuchProcess(org.zeroturnaround.exec.InvalidExitValueException e)
Returns:
true if this exception indicates that the process was not found (any more).


Copyright © 2015 ZeroTurnaround. All rights reserved.