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
}
Execute, org.apache.tools.ant.util.Watchdog
| Modifier and Type | Field and Description |
|---|---|
| private Exception | caught
exception that might be thrown during the process execution |
| private volatile boolean | killedProcess
say whether or not the process was killed due to running overtime |
| private Process | process
the process to execute and watch for duration |
| private volatile boolean | watch
say whether or not the watchdog is currently monitoring a process |
| private Watchdog | watchdog
will tell us whether timeout has occurred |
| Access | Constructor and Description |
|---|---|
| public | ExecuteWatchdog(long
the timeout for the process in milliseconds.
It must be greater than 0. timeout)Creates a new watchdog with a given timeout. |
| public | ExecuteWatchdog(int
the timeout value to use in milliseconds. timeout)
Deprecated
since 1.5.x.
Use constructor with a long type instead.
(1.4.x compatibility)
|
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | checkException()
This method will rethrow the exception that was possibly caught during the run of the process. |
| protected synchronized void | |
| public boolean | Returns: true if the process is still running, otherwise
false.Indicates whether or not the watchdog is still monitoring the process. |
| public boolean | Returns: true if the process was killed otherwise
false.Indicates whether the last process run was killed on timeout or not. |
| public synchronized void | |
| public synchronized void | |
| public synchronized void | timeoutOccured(Watchdog
the watchdog w)Implements org. |
| caught | back to summary |
|---|---|
| private Exception caught exception that might be thrown during the process execution | |
| killedProcess | back to summary |
|---|---|
| private volatile boolean killedProcess say whether or not the process was killed due to running overtime | |
| process | back to summary |
|---|---|
| private Process process the process to execute and watch for duration | |
| watch | back to summary |
|---|---|
| private volatile boolean watch say whether or not the watchdog is currently monitoring a process | |
| watchdog | back to summary |
|---|---|
| private Watchdog watchdog will tell us whether timeout has occurred | |
| ExecuteWatchdog | back to summary |
|---|---|
| public ExecuteWatchdog(long timeout) Creates a new watchdog with a given timeout.
| |
| ExecuteWatchdog | back to summary |
|---|---|
| public ExecuteWatchdog(int timeout)
Deprecated since 1.5.x. Use constructor with a long type instead. (1.4.x compatibility)
| |
| checkException | back to summary |
|---|---|
| public synchronized void checkException() throws BuildException This method will rethrow the exception that was possibly caught during the run of the process. It will only remains valid once the process has been terminated either by 'error', timeout or manual intervention. Information will be discarded once a new process is ran.
| |
| cleanUp | back to summary |
|---|---|
| protected synchronized void cleanUp() reset the monitor flag and the process. | |
| isWatching | back to summary |
|---|---|
| public boolean isWatching() Indicates whether or not the watchdog is still monitoring the process.
| |
| killedProcess | back to summary |
|---|---|
| public boolean killedProcess() Indicates whether the last process run was killed on timeout or not.
| |
| start | back to summary |
|---|---|
| public synchronized void start(Process process) Watches the given process and terminates it, if it runs for too long. All information from the previous run are reset.
| |
| stop | back to summary |
|---|---|
| public synchronized void stop() Stops the watcher. It will notify all threads possibly waiting on this object. | |
| timeoutOccured | back to summary |
|---|---|
| public synchronized void timeoutOccured(Watchdog w) Implements org. Called after watchdog has finished. This can be called in the watchdog thread | |