public class ExecuteWatchdog extends java.lang.Object implements TimeoutObserver
ExecuteWatchdog watchdog = new ExecuteWatchdog(30000);
Execute exec = new Execute(myloghandler, watchdog);
exec.setCommandLine(mycmdline);
int exitvalue = exec.execute();
if (Execute.isFailure(exitvalue) && watchdog.killedProcess()) {
// it was killed on purpose by the watchdog
}
| Constructor and Description |
|---|
ExecuteWatchdog(int timeout)
Deprecated.
since 1.5.x.
Use constructor with a long type instead.
(1.4.x compatibility)
|
ExecuteWatchdog(long timeout)
Creates a new watchdog with a given timeout.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkException()
This method will rethrow the exception that was possibly caught during
the run of the process.
|
protected void |
cleanUp()
reset the monitor flag and the process.
|
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 |
start(java.lang.Process process)
Watches the given process and terminates it, if it runs for too long.
|
void |
stop()
Stops the watcher.
|
void |
timeoutOccured(Watchdog w)
Called after watchdog has finished.
|
public ExecuteWatchdog(long timeout)
timeout - the timeout for the process in milliseconds.
It must be greater than 0.@Deprecated public ExecuteWatchdog(int timeout)
timeout - the timeout value to use in milliseconds.ExecuteWatchdog(long)public void start(java.lang.Process process)
process - the process to monitor. It cannot be nulljava.lang.IllegalStateException - if a process is still being monitored.public void stop()
public void timeoutOccured(Watchdog w)
timeoutOccured in interface TimeoutObserverw - the watchdogprotected void cleanUp()
public void checkException()
throws BuildException
BuildException - a wrapped exception over the one that was
silently swallowed and stored during the process run.public boolean isWatching()
public boolean killedProcess()