org.zeroturnaround.process
Class WindowsProcess
java.lang.Object
org.zeroturnaround.process.AbstractProcess
org.zeroturnaround.process.PollingProcess
org.zeroturnaround.process.PidProcess
org.zeroturnaround.process.WindowsProcess
- All Implemented Interfaces:
- SystemProcess
public class WindowsProcess
- extends PidProcess
Process implementation for Windows PID values.
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.
| Fields inherited from class org.zeroturnaround.process.PidProcess |
pid |
WindowsProcess
public WindowsProcess(int pid)
isGracefulDestroyEnabled
public boolean isGracefulDestroyEnabled()
setGracefulDestroyEnabled
public void setGracefulDestroyEnabled(boolean gracefulDestroyEnabled)
isIncludeChildren
public boolean isIncludeChildren()
setIncludeChildren
public void setIncludeChildren(boolean includeChildren)
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
taskkill
public boolean taskkill(boolean forceful)
throws IOException,
InterruptedException
- Sends the destroy signal to this process.
- Parameters:
forceful - true if this process should be destroyed forcefully.
- Returns:
true if this process got the signal, false if the process was not found (any more).
- Throws:
IOException
InterruptedException
Copyright © 2015 ZeroTurnaround. All rights reserved.