bodewig 01/01/31 07:55:49
Modified: src/main/org/apache/tools/ant/taskdefs ExecuteWatchdog.java
Log:
Make sure the watched process is running before we kill it.
Submitted by: Stephane Bailliez <[EMAIL PROTECTED]>
Revision Changes Path
1.5 +15 -5
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
Index: ExecuteWatchdog.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExecuteWatchdog.java 2001/01/30 17:01:24 1.4
+++ ExecuteWatchdog.java 2001/01/31 15:55:47 1.5
@@ -147,11 +147,21 @@
wait(until - now);
} catch (InterruptedException e) {}
}
- // if we are here, either someone stopped the watchdog or we are
on timeout
- // if watch is true, it means its a timeout
- if (watch) {
- killedProcess = true;
- process.destroy();
+
+ // if we are here, either someone stopped the watchdog,
+ // we are on timeout and the process must be killed, or
+ // we are on timeout and the process has already stopped.
+ try {
+ // We must check if the process was not stopped
+ // before being here
+ process.exitValue();
+ } catch (IllegalThreadStateException e){
+ // the process is not terminated, if this is really
+ // a timeout and not a manual stop then kill it.
+ if (watch){
+ killedProcess = true;
+ process.destroy();
+ }
}
} catch(Exception e) {
caught = e;