Try calling .exitValue() after the .waitFor() returns. It seems like both .waitFor() and .exitValue() would return the same value (based on looking at the JAVA API) however in my experience the .exitValue() seems to give me the sub-process value more realiably.
Process p = pb.start(); int r = p.waitFor(); // <------------------------------ this always returns 0 if ( r == 0 ) { int exitValue = p.exitValue(); if (exitValue == 0) { System.out.println("OK"); } else { System.out.println("FAILED"); System.exit(5); } } else { System.out.println("FAILED"); System.exit(5); } ----- Original Message ---- From: Jose Antonio Pla Rodriguez <[EMAIL PROTECTED]> To: user@ant.apache.org Sent: Saturday, February 17, 2007 1:33:54 AM Subject: return status problem in ant.bat Hello list: I am programming a java application than execute a shell command and gets the return status, with this value I can know if the process success (return status equals 0) or failed (return status not equals 0). The problem is that every time I run the ant program by a call to ant.bat I always get cero ( 0 ) as return status, even when the build is halted explicitly (<fail/>) or when are evident errors ( like a execution of an inexistent target or an inexistent build.xml ) I get this problem in: Windows XP SP2 Apache ant 1.6.5 I tried version 1.7.0 with seem results Can some one tell me why the ant.bat always returns a status 0 independently of the result of the build process?? There is any way to know if a build process success or fails?? This is a snippet of my code: ProcessBuilder pb = new ProcessBuilder(new String[]{"ant","zzzzzzz"}); // task zzzzzzz does not exist. Process p = pb.start(); int r = p.waitFor(); // <------------------------------ this always returns 0 if ( r == 0 ) System.out.println("OK"); else System.out.println("FAILED"); Regards, Pla. ____________________________________________________________________________________ No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]