org.apache.tools.ant.taskdefs
public class ExecuteWatchdog extends 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
}
Since: Ant 1.2
| Constructor Summary | |
|---|---|
| ExecuteWatchdog(long timeout)
Creates a new watchdog with a given timeout.
| |
| ExecuteWatchdog(int timeout) | |
| Method Summary | |
|---|---|
| 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(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.
|
Parameters: timeout the timeout for the process in milliseconds. It must be greater than 0.
Deprecated: since 1.5.x. Use constructor with a long type instead. (1.4.x compatibility)
Parameters: timeout the timeout value to use in milliseconds.
See Also: ExecuteWatchdog
Throws: BuildException a wrapped exception over the one that was silently swallowed and stored during the process run.
Returns: true if the process is still running, otherwise false.
Returns: true if the process was killed otherwise false.
Parameters: process the process to monitor. It cannot be null
Throws: IllegalStateException if a process is still being monitored.
Parameters: w the watchdog