|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zeroturnaround.process.ProcessUtil
public class ProcessUtil
Additional helper methods for killing processes and waiting until they finish.
Here all methods that use a timeout throw TimeoutException including the given timeout in the message
instead of returning a false like SystemProcess does.
Also all methods log a message in case the operation succeeded including the time it took.
Notice that methods that destroy a process don't include destroying operation itself in the timeout period. They start measuring time after sending the destroy signal. Also if the current thread gets interrupted it may also interrupt sending the destroy signal itself not just the waiting period after it. So if the current thread gets interrupted there's no guarantee that the target process actually got signaled.
SystemProcess| Constructor Summary | |
|---|---|
ProcessUtil()
|
|
| Method Summary | |
|---|---|
static void |
destroyForcefullyAndWait(SystemProcess process)
Destroys the given process forcefully and waits until it finishes or the current thread gets interrupted. |
static void |
destroyForcefullyAndWait(SystemProcess process,
long timeout,
TimeUnit unit)
Destroys the given process forcefully and waits until it finishes, a timeout occurs or the current thread gets interrupted. |
static void |
destroyGracefullyAndWait(SystemProcess process)
Destroys the given process gracefully and waits until it finishes or the current thread gets interrupted. |
static void |
destroyGracefullyAndWait(SystemProcess process,
long timeout,
TimeUnit unit)
Destroys the given process gracefully and waits until it finishes, a timeout occurs or the current thread gets interrupted. |
static void |
destroyGracefullyOrForcefullyAndWait(SystemProcess process)
Destroys the given process gracefully and waits until it finishes or the current thread gets interrupted. |
static void |
destroyGracefullyOrForcefullyAndWait(SystemProcess process,
long gracefulTimeout,
TimeUnit gracefulTimeoutUnit)
Destroys the given process gracefully and waits until it finishes, a timeout occurs or the current thread gets interrupted. |
static void |
destroyGracefullyOrForcefullyAndWait(SystemProcess process,
long gracefulTimeout,
TimeUnit gracefulTimeoutUnit,
long forcefulTimeout,
TimeUnit forcefulTimeoutUnit)
Destroys the given process gracefully and waits until it finishes, first timeout occurs or the current thread gets interrupted. |
static void |
waitFor(SystemProcess process)
Waits until the given process finishes or the current thread gets interrupted. |
static void |
waitFor(SystemProcess process,
long timeout,
TimeUnit unit)
Waits until the given process finishes, a timeout occurs or the current thread gets interrupted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProcessUtil()
| Method Detail |
|---|
public static void waitFor(SystemProcess process)
throws InterruptedException
process - the target process.
InterruptedException - if the current thread gets interrupted.
public static void waitFor(SystemProcess process,
long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException
process - the target process.timeout - the maximum time to wait until the process finishes.unit - the time unit of the timeout argument.
InterruptedException - if the current thread gets interrupted.
TimeoutException - the timeout elapsed before the process finished.
public static void destroyGracefullyAndWait(SystemProcess process)
throws IOException,
InterruptedException
process - the target process.
InterruptedException - if the current thread gets interrupted.
IOException
public static void destroyGracefullyAndWait(SystemProcess process,
long timeout,
TimeUnit unit)
throws IOException,
InterruptedException,
TimeoutException
process - the target process.timeout - the maximum time to wait until the process finishes.unit - the time unit of the timeout argument.
InterruptedException - if the current thread gets interrupted.
TimeoutException - the timeout elapsed before the process finished.
IOException
public static void destroyForcefullyAndWait(SystemProcess process)
throws IOException,
InterruptedException
process - the target process.
InterruptedException - if the current thread gets interrupted.
IOException
public static void destroyForcefullyAndWait(SystemProcess process,
long timeout,
TimeUnit unit)
throws IOException,
InterruptedException,
TimeoutException
process - the target process.timeout - the maximum time to wait until the process finishes.unit - the time unit of the timeout argument.
InterruptedException - if the current thread gets interrupted.
TimeoutException - the timeout elapsed before the process finished.
IOException
public static void destroyGracefullyOrForcefullyAndWait(SystemProcess process)
throws IOException,
InterruptedException
process - the target process.
InterruptedException - if the current thread gets interrupted.
IOException
public static void destroyGracefullyOrForcefullyAndWait(SystemProcess process,
long gracefulTimeout,
TimeUnit gracefulTimeoutUnit)
throws IOException,
InterruptedException
process - the target process.timeout - the maximum time to wait until the process finishes after the gracefully destroying operation.unit - the time unit of the timeout argument.
InterruptedException - if the current thread gets interrupted.
IOException
public static void destroyGracefullyOrForcefullyAndWait(SystemProcess process,
long gracefulTimeout,
TimeUnit gracefulTimeoutUnit,
long forcefulTimeout,
TimeUnit forcefulTimeoutUnit)
throws IOException,
InterruptedException,
TimeoutException
process - the target process.gracefulTimeout - the maximum time to wait until the process finishes after the gracefully destroying operation.gracefulTimeoutUnit - the time unit of the first timeout argument.forcefulTimeout - the maximum time to wait until the process finishes after the forcefully destroying operation.forcefulTimeoutUnit - the time unit of the second timeout argument.
InterruptedException - if the current thread gets interrupted.
TimeoutException - the timeout elapsed before the process finished after the forcefully destroying operation.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||