ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MNewc...@tacintel.com
Subject [PATCH] Execute.java now registers forked processes so they are d estroyed when VM exits (i.e. ctrl-C)
Date Wed, 21 Nov 2001 20:57:53 GMT
I sit behind a firewall and therefore can use CVS directly.  Hopefully I
have put enough information to get this patch through.

DESCRIPTION:
When you fork off processes in Ant, they don't get notified when Ant is
destroyed.  This patch registers a shutdown hook (if
Runtime.addShutdownHook() is available) that destroys all processes that
have been registered with it.  After the process finishes, it is removed
from the list.

ATTACHED FILES:
ProcessDestroyer.java (new file, currently in the
org.apache.tools.ant.taskdefs package)
patchfile.txt
testcase.zip (contains test case for fix)

TEST CASE:
testcase.zip contains:
TestProcess.java
build.xml

TestProcess.java just loops 5 times (sleeping for 2 seconds) then exits.  If
you press ctrl-C, the shutdown hook runs and terminates the thread early.

When you run with Ant 1.4.1, and hit ctrl-C, you get the following output
(shutdown hook doesn't run):

C:\TEMP\tmp>ant
Buildfile: build.xml

compile:
    [javac] Compiling 1 source file

main:
     [java] TestProcess thread
     [java] TestProcess thread
     [java] TestProcess thread
C:\TEMP\tmp>

When you run with the patch, and hit ctrl-C, you get the following output
(shutdown hook runs):

C:\TEMP\tmp>ant
Buildfile: build.xml

compile:

main:
     [java] TestProcess thread
     [java] TestProcess thread
     [java] shutting down TestProcess
C:\TEMP\tmp>

 <<ProcessDestroyer.java>>  <<patchfile.txt>>  <<testcase.zip>>


Mime
View raw message