public class ExecuteWatchdog
extends java.lang.Object
implements java.lang.Runnable
ExecuteWatchdog watchdog = new ExecuteWatchdog(30000);
Execute exec = new Execute(myloghandler, watchdog);
exec.setCommandLine(mycmdline);
int exitvalue = exec.execute();
if (exitvalue != SUCCESS && watchdog.killedProcess()){
// it was killed on purpose by the watchdog
}
Execute| Constructor and Description |
|---|
ExecuteWatchdog(int timeout)
Creates a new watchdog with a given timeout.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanUp()
reset the monitor flag and the process.
|
java.lang.Exception |
getException() |
boolean |
isWatching()
Indicates whether or not the watchdog is still monitoring the process.
|
boolean |
killedProcess()
Indicates whether the last process run was killed on timeout or not.
|
void |
run()
Watches the process and terminates it, if it runs for too long.
|
void |
setDontkill(boolean b) |
void |
start(java.lang.Process process,
java.lang.Thread execThread)
Watches the given process and terminates it, if it runs for too long.
|
void |
stop()
Stops the watcher.
|
public ExecuteWatchdog(int timeout)
timeout - the timeout for the process in milliseconds. It must be greather than 0.public void setDontkill(boolean b)
public void start(java.lang.Process process,
java.lang.Thread execThread)
process - the process to monitor. It cannot be nullexecThread - The thread.java.lang.IllegalStateException - thrown if a process is still being monitored.public void stop()
public void run()
run in interface java.lang.Runnableprotected void cleanUp()
public java.lang.Exception getException()
public boolean isWatching()
public boolean killedProcess()