DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8510>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8510 shutdown hook does not fire in forked java task under JDK1.4 [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Target Milestone|--- |1.6 ------- Additional Comments From [EMAIL PROTECTED] 2003-07-15 07:23 ------- I have resolved some aspects of this bug, although it mainly applies to Unix systems (more on that in a minute). Under Ant 1.5 under Linux, the ProcessDestroyer does not wait for the terminating processes to complete their shutdowns. If they have anything more than a trivial shutdown process, it would get truncated as the Ant VM shuts down. The ProcessDestroyer also blocked Execute.java in the remove() method as it held the lock on the processes object. So even if the process managed to generate output, it may not have made it to the Ant output log. Under Windows and JDK 1.4, the process shutdown hooks are not fired. This is marked by Sun as "not a bug". See http://developer.java.sun.com/developer/bugParade/bugs/4485742.html although http://developer.java.sun.com/developer/bugParade/bugs/4671966.html may be able to change that. JDK 1.3 appears to fire the shutdown hook on Windows but it is something of an illusion as the shutdown is not allowed to complete. If you put this in the given Demo class' run method System.err.println("DEMO shutdown hook fired"); try { PrintWriter pw = new PrintWriter(new FileOutputStream("test.txt")); Thread.currentThread().sleep(3000); pw.println("Test"); pw.close(); } catch (Exception e) { } System.err.flush(); you will find that test.txt is created but no content is written. This works under Linux. Note that the use of output or error streams to determine if the shutdown hook has fired or not is suspect. The above file based approach is more conclusive. This is because the output generated may still be within a couple of Ant stream processing threads (daemons) which get terminated in the shutdown process. The Main.java does not really demonstrate a problem. It gives no info about the firing of the shutdown hook in the subprocess. In fact it has the same behaviour as Ant - the subprocess shutdown is not fired. It is indeed a JVM bug^H^H^Hfeature. I'm marking as fixed from Ant's point of view. You need to lobby Sun to address the shutdown issues under windows. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]