Hi,

actually your new solution was my first approach which I left because of this documentation,
regarding option 1
wouldn't this still need a patch to set killedProcess() to true (i know horrible way to say what I mean, but this should be clear) when destroy is called via the InterruptedException in the waitFor method.


===PATCH===
Index: src/main/org/apache/tools/ant/taskdefs/Execute.java
===================================================================
RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
retrieving revision 1.66
diff -u -r1.66 Execute.java
--- src/main/org/apache/tools/ant/taskdefs/Execute.java 13 Sep 2003 12:58:33 -0000 1.66
+++ src/main/org/apache/tools/ant/taskdefs/Execute.java 17 Sep 2003 18:25:49 -0000
@@ -78,6 +78,7 @@
* @author [EMAIL PROTECTED]
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Tulley</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Charles Hudak</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Martijn Kruithof</a>
*
* @since Ant 1.2
*
@@ -96,6 +97,7 @@
private File workingDirectory = null;
private Project project = null;
private boolean newEnvironment = false;
+ private boolean killed = false;



/** Controls whether the VM is used to launch commands, where possible */
private boolean useVMLauncher = true;
@@ -512,6 +514,9 @@



if (watchdog != null) { watchdog.checkException(); + if (watchdog != null && watchdog.killedProcess()) { + killed = true; + } } return getExitValue(); } finally { @@ -555,6 +560,7 @@ setExitValue(process.exitValue()); } catch (InterruptedException e) { process.destroy(); + killed = true; } }


@@ -569,7 +575,7 @@


/** * Query the exit value of the process. - * @return the exit value, 1 if the process was killed, + * @return the exit value * or Execute.INVALID if no exit value has been received */ public int getExitValue() { @@ -607,7 +613,7 @@ * @since Ant 1.5 */ public boolean killedProcess() { - return watchdog != null && watchdog.killedProcess(); + return killed; }


/** @@ -1153,4 +1159,4 @@ }


} -} \ No newline at end of file +} ===END PATCH===



-----Ursprungliche Nachricht----- Von: Stefan Bodewig [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 17. September 2003 10:38 An: [EMAIL PROTECTED] Betreff: Execute#getExitCode doesn't work as advertised


Martijn Kruithof raised this issue in his patch for PR 23150.

The javadocs say

     * @return the exit value, 1 if the process was killed,

but in fact, it doesn't do anything special for a killed process.

Rather than "fixing" this method, I'd like to remove the comment.
For two reasons

(1) Execute#killedProcess can always be consulted

(2) more important to me - 1 means success on OpenVMS, so any hard
    coded constant here would be wrong IMHO.

Comments?

Stefan




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to