Package 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
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.
-
Field Summary
Fields inherited from class org.zeroturnaround.process.PidProcess
pidFields inherited from class org.zeroturnaround.process.AbstractProcess
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy(boolean forceful) Destroys the process either forcefully or gracefully according to the given option.booleanisAlive()Tests whether this process is alive.booleanbooleanvoidsetGracefulDestroyEnabled(boolean gracefulDestroyEnabled) voidsetIncludeChildren(boolean includeChildren) voidsetWmicPath(File wmicPath) booleantaskkill(boolean forceful) Sends the destroy signal to this process.Methods inherited from class org.zeroturnaround.process.PidProcess
getDescription, getPidMethods inherited from class org.zeroturnaround.process.PollingProcess
getIntervalForCheckingFinished, setIntervalForCheckingFinished, waitForMethods inherited from class org.zeroturnaround.process.AbstractProcess
destroyForcefully, destroyGracefully, toString, waitFor
-
Constructor Details
-
WindowsProcess
public WindowsProcess(int pid) -
WindowsProcess
-
-
Method Details
-
getWmicPath
-
setWmicPath
-
isGracefulDestroyEnabled
public boolean isGracefulDestroyEnabled() -
setGracefulDestroyEnabled
public void setGracefulDestroyEnabled(boolean gracefulDestroyEnabled) -
isIncludeChildren
public boolean isIncludeChildren() -
setIncludeChildren
public void setIncludeChildren(boolean includeChildren) -
isAlive
Description copied from interface:SystemProcessTests whether this process is alive.This operation may take some time to finish.
- Returns:
trueif this process is alive,falseif it is finished or not found.- Throws:
IOException- on IO error.InterruptedException- if interrupted.
-
destroy
Description copied from class:AbstractProcessDestroys the process either forcefully or gracefully according to the given option.Note: The process may not terminate at all. i.e.
isAlive()may returntruefor a any period afterdestroy()is called. This method may be chained towaitFor()if needed.No error is thrown if the process was already terminated.
- Specified by:
destroyin classAbstractProcess- Parameters:
forceful-trueif the process must be destroyed forcefully (likekill -KILL),falseif it must be destroyed gracefully (likekill -TERM).- Throws:
IOException- on IO error.InterruptedException- if interrupted.
-
taskkill
Sends the destroy signal to this process.- Parameters:
forceful-trueif this process should be destroyed forcefully.- Returns:
trueif this process got the signal,falseif the process was not found (any more).- Throws:
IOException- on IO error.InterruptedException- if interrupted.
-