conor 2003/07/15 00:19:15
Modified: src/main/org/apache/tools/ant/taskdefs Execute.java
ExecuteWatchdog.java ProcessDestroyer.java
src/main/org/apache/tools/ant/util Watchdog.java
Log:
Ensure terminated processes are allowed to complete before finishing the
Ant shutdown
PR: 8510
Revision Changes Path
1.56 +21 -18 ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
Index: Execute.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -w -u -r1.55 -r1.56
--- Execute.java 23 May 2003 13:40:37 -0000 1.55
+++ Execute.java 15 Jul 2003 07:19:14 -0000 1.56
@@ -450,6 +450,7 @@
}
streamHandler.start();
+ try {
// add the process to the list of those to destroy if the VM exits
//
processDestroyer.add(process);
@@ -459,18 +460,20 @@
}
waitFor(process);
- // remove the process to the list of those to destroy if the VM exits
- //
- processDestroyer.remove(process);
-
if (watchdog != null) {
watchdog.stop();
}
streamHandler.stop();
+
if (watchdog != null) {
watchdog.checkException();
}
return getExitValue();
+ } finally {
+ // remove the process to the list of those to destroy if the VM
exits
+ //
+ processDestroyer.remove(process);
+ }
}
protected void waitFor(Process process) {
1.14 +1 -1
ant/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
Index: ExecuteWatchdog.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -u -r1.13 -r1.14
1.10 +8 -0
ant/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java
Index: ProcessDestroyer.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -u -r1.9 -r1.10
--- ProcessDestroyer.java 14 Jul 2003 16:02:41 -0000 1.9
+++ ProcessDestroyer.java 15 Jul 2003 07:19:15 -0000 1.10
@@ -214,6 +214,7 @@
synchronized (processes) {
boolean processRemoved = processes.removeElement(process);
if (processes.size() == 0) {
+ processes.notify();
removeShutdownHook();
}
return processRemoved;
@@ -228,6 +229,13 @@
Enumeration e = processes.elements();
while (e.hasMoreElements()) {
((Process) e.nextElement()).destroy();
+ }
+
+ try {
+ // wait for all processes to finish
+ processes.wait();
+ } catch (InterruptedException interrupt) {
+ // ignore
}
}
}
1.5 +2 -1 ant/src/main/org/apache/tools/ant/util/Watchdog.java
Index: Watchdog.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/Watchdog.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- Watchdog.java 7 Mar 2003 11:23:08 -0000 1.4
+++ Watchdog.java 15 Jul 2003 07:19:15 -0000 1.5
@@ -114,7 +114,8 @@
while (!stopped && until > (now = System.currentTimeMillis())) {
try {
wait(until - now);
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ }
}
if (!stopped) {
fireTimeoutOccured();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]