public class JavaProcess extends AbstractProcess
Process.| Modifier and Type | Field and Description |
|---|---|
protected Process |
process
The wrapped process.
|
log| Modifier | Constructor and Description |
|---|---|
protected |
JavaProcess(Process process) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canDestroy(boolean forceful)
Check if destroying the process is supported based on the OS and JVM version (regardless the process is running or not).
|
void |
destroy(boolean forceful)
Destroys the process either forcefully or gracefully according to the given option.
|
String |
getDescription() |
Process |
getProcess()
Returns the wrapped process.
|
protected void |
invokeDestroy(boolean forceful) |
boolean |
isAlive()
Tests whether this process is alive.
|
void |
waitFor()
Causes the current thread to wait, if necessary, until this process has terminated.
|
destroyForcefully, destroyGracefully, toString, waitForprotected final Process process
protected JavaProcess(Process process)
public Process getProcess()
public String getDescription()
getDescription in class AbstractProcesspublic boolean isAlive()
SystemProcessThis operation may take some time to finish.
true if this process is alive, false if it is finished or not found.public void waitFor()
throws InterruptedException
SystemProcessThis method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits.
InterruptedException - if interrupted.public void destroy(boolean forceful)
throws IOException
AbstractProcess
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.
destroy in class AbstractProcessforceful - true if the process must be destroyed forcefully (like kill -KILL),
false if it must be destroyed gracefully (like kill -TERM).IOException - on IO error.protected boolean canDestroy(boolean forceful)
forceful - true if the process must be destroyed forcefully (like kill -KILL),
false if it must be destroyed gracefully (like kill -TERM).true if invokeDestroy(boolean) is supported with the given forceful flag on the given system.protected void invokeDestroy(boolean forceful)
Copyright © 2019 ZeroTurnaround. All rights reserved.