org.zeroturnaround.process
Class UnixProcess
java.lang.Object
org.zeroturnaround.process.AbstractProcess
org.zeroturnaround.process.PollingProcess
org.zeroturnaround.process.PidProcess
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.
| Fields inherited from class org.zeroturnaround.process.PidProcess |
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. |
UnixProcess
public UnixProcess(int pid)
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.