public abstract class AbstractProcess extends Object implements SystemProcess
SystemProcess.| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
| Constructor and Description |
|---|
AbstractProcess() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
destroy(boolean forceful)
Destroys the process either forcefully or gracefully according to the given option.
|
AbstractProcess |
destroyForcefully()
Kills this process.
|
AbstractProcess |
destroyGracefully()
Terminates this process.
|
protected abstract String |
getDescription() |
String |
toString() |
boolean |
waitFor(long timeout,
TimeUnit unit)
Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified timeout is reached.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisAlive, waitForprotected abstract String getDescription()
public boolean waitFor(long timeout,
TimeUnit unit)
throws InterruptedException
If the process has already terminated then this method returns immediately with the value true.
If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the value false.
waitFor in interface SystemProcesstimeout - the maximum time to waitunit - the time unit of the timeout argumenttrue if the process has exited and false if the timeout is reached before the process has exited.InterruptedException - if interrupted.public AbstractProcess destroyGracefully() throws IOException, InterruptedException
kill -TERM does).
Note: The process may not terminate at all.
i.e. isAlive() may return true for a any period after destroyGracefully() is called.
This method may be chained to waitFor() if needed.
No error is thrown if the process was already terminated.
destroyGracefully in interface SystemProcessUnsupportedOperationException - if this implementation is unable to gracefully terminate the process.IOException - on IO error.InterruptedException - if interrupted.public AbstractProcess destroyForcefully() throws IOException, InterruptedException
kill -KILL does).
Note: The process may not terminate immediately.
i.e. isAlive() may return true for a brief period after destroyForcefully() is called.
This method may be chained to waitFor() if needed.
No error is thrown if the process was already terminated.
destroyForcefully in interface SystemProcessUnsupportedOperationException - if this implementation is unable to gracefully terminate the process.IOException - on IO error.InterruptedException - if interrupted.public abstract void destroy(boolean forceful)
throws IOException,
InterruptedException
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.
forceful - true if the process must be destroyed forcefully (like kill -KILL),
false if it must be destroyed gracefully (like kill -TERM).UnsupportedOperationException - if this implementation is unable to terminate the process with this forceful value.IOException - on IO error.InterruptedException - if interrupted.Copyright © 2019 ZeroTurnaround. All rights reserved.