Class AndProcess
- All Implemented Interfaces:
SystemProcess
It tries to kill all child processes.
If it fails to destroy any process it still tries to destroy other processes before actually throwing the initial error.
isAlive() returns true if at least one of the processes is still alive.
isAllAlive() returns true only if all processes are still alive.
If it has only one child it acts the same as invoking the same method directly on the child.
-
Field Summary
Fields inherited from class org.zeroturnaround.process.CompositeProcess
childrenFields 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.booleanvoidwaitFor()Causes the current thread to wait, if necessary, until this process has terminated.Methods inherited from class org.zeroturnaround.process.CompositeProcess
getDescription, invokeDestroy, toStringMethods inherited from class org.zeroturnaround.process.AbstractProcess
destroyForcefully, destroyGracefully, waitFor
-
Constructor Details
-
AndProcess
-
-
Method Details
-
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.
-
isAllAlive
- Throws:
IOExceptionInterruptedException
-
waitFor
Description copied from interface:SystemProcessCauses the current thread to wait, if necessary, until this process has terminated.This 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.
- Throws:
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.
-