public class WindowsProcess extends PidProcess
It uses wmic for checking the process status and taskkill command for destroying the process.
Although the taskkill command officially supports killing both forcefully or gracefully
we expect it to fail killing anything gracefully by default and we throw UnsupportedOperationException.
To enable this operation call setGracefulDestroyEnabled(boolean) with true first.
pidlog| Constructor and Description |
|---|
WindowsProcess(int pid) |
WindowsProcess(int pid,
File wmicPath) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy(boolean forceful)
Destroys the process either forcefully or gracefully according to the given option.
|
File |
getWmicPath() |
boolean |
isAlive()
Tests whether this process is alive.
|
boolean |
isGracefulDestroyEnabled() |
boolean |
isIncludeChildren() |
void |
setGracefulDestroyEnabled(boolean gracefulDestroyEnabled) |
void |
setIncludeChildren(boolean includeChildren) |
void |
setWmicPath(File wmicPath) |
boolean |
taskkill(boolean forceful)
Sends the destroy signal to this process.
|
getDescription, getPidgetIntervalForCheckingFinished, setIntervalForCheckingFinished, waitFordestroyForcefully, destroyGracefully, toString, waitForpublic WindowsProcess(int pid)
public WindowsProcess(int pid,
File wmicPath)
public File getWmicPath()
public void setWmicPath(File wmicPath)
public boolean isGracefulDestroyEnabled()
public void setGracefulDestroyEnabled(boolean gracefulDestroyEnabled)
public boolean isIncludeChildren()
public void setIncludeChildren(boolean includeChildren)
public boolean isAlive()
throws IOException,
InterruptedException
SystemProcessThis operation may take some time to finish.
true if this process is alive, false if it is finished or not found.IOException - on IO error.InterruptedException - if interrupted.public void destroy(boolean forceful)
throws IOException,
InterruptedException
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.InterruptedException - if interrupted.public boolean taskkill(boolean forceful)
throws IOException,
InterruptedException
forceful - true if this process should be destroyed forcefully.true if this process got the signal, false if the process was not found (any more).IOException - on IO error.InterruptedException - if interrupted.Copyright © 2019 ZeroTurnaround. All rights reserved.