|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface SystemProcess
Represents a native system process.
This interface provides methods for checking aliveness, waiting for the process to complete and destroying (killing) the process. It does not have methods to control streams or check exit status of the process.
It is implementation specific whether the represented system process is a sub process of this JVM or some external process referred by a process ID, service name or etc. An instance of this class may also represent more than one process. In this case it is considered alive as long as any of the processes is alive.
Some of the operations may be unsupported by throwing UnsupportedOperationException.
Processes,
ProcessUtil| Method Summary | |
|---|---|
SystemProcess |
destroyForcefully()
Kills this process. |
SystemProcess |
destroyGracefully()
Terminates this process. |
boolean |
isAlive()
Tests whether this process is alive. |
void |
waitFor()
Causes the current thread to wait, if necessary, until this process has terminated. |
boolean |
waitFor(long timeout,
TimeUnit unit)
Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified waiting time elapses. |
| Method Detail |
|---|
boolean isAlive()
throws IOException,
InterruptedException
This operation may also take some time to finish.
true if this process is alive, false if it is finished or not found.
IOException
InterruptedException
void waitFor()
throws InterruptedException
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.
InterruptedException
boolean waitFor(long timeout,
TimeUnit unit)
throws InterruptedException
If the process has already terminated then this method returns immediately with the value true.
If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the value false.
Checking the process status itself may also take time.
If the process has exited but timeout is reached before the checking operation finishes false is returned.
timeout - the maximum time to waitunit - the time unit of the timeout argument
true if the process has exited and false if the waiting time elapsed before the process has exited.
InterruptedException
SystemProcess destroyGracefully()
throws IOException,
InterruptedException,
UnsupportedOperationException
kill -TERM does).
Note: The process may not terminate at all.
i.e. isAlive() may return true for any period after destroyGracefully() is called.
This method may be chained to waitFor() if needed.
If this process was already finished (or it was not found) this method finishes without throwing any errors.
UnsupportedOperationException - if this implementation cannot gracefully terminate any process.
IOException
InterruptedException
SystemProcess destroyForcefully()
throws IOException,
InterruptedException,
UnsupportedOperationException
kill -KILL does).
Note: The process may not terminate immediately.
i.e. isAlive() may return true for a brief period after destroyForcefully() is called.
This method may be chained to waitFor() if needed.
If this process was already finished (or it was not found) this method finishes without throwing any errors.
UnsupportedOperationException - if this implementation cannot forcibly terminate any process.
IOException
InterruptedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||