Yes.

Adam Bruss
Senior Development Engineer
AWR Corporation
11520 N. Port Washington Rd., Suite 201
Mequon, WI  53092  USA
P: 1.262.240.0291 x104
F: 1.262.240.0294
E: abr...@awrcorp.com
W: http://www.awrcorp.com

-----Original Message-----
From: Vimil Saju [mailto:vimils...@yahoo.com] 
Sent: Wednesday, February 08, 2012 10:18 AM
To: Ant Users List
Subject: Re: Regarding exec task

This sounds good, but won't it kill processes that wasn't started by my script 
too?


________________________________
 From: Adam Bruss <abr...@awrcorp.com>
To: Ant Users List <user@ant.apache.org>; Vimil Saju <vimils...@yahoo.com> 
Sent: Wednesday, February 8, 2012 6:34 AM
Subject: RE: Regarding exec task
 
Set failonerror=false on the parent tasks. Get the return code. If return code 
not 0 then call a common target which executes your own personal 
"kill-zombie-processes" task and then fails the build using <fail>. 
"kill-zombie-processes" kills all possible still running child processes. You 
need to know what the process names are. It's different than what you asked for 
but it works for me.

My kill target:

                <target name="kill-zombie-test-processes">
        <if><not><isset property="os_is_unix"/></not>
            <then>
                <echo message="Killing all existing test processes..." 
level="info"/>
                <exec executable="taskkill" failonerror="false">
                    <arg value="/F"/>
                    <arg value="/T"/>
                    <arg value="/IM"/>
                    <arg value="tc.exe"/>
                    <arg value="/IM"/>
                    <arg value="analyst.exe"/>
                    <arg value="/IM"/>
                    <arg value="grsim.exe"/>
                    <arg value="/IM"/>
                    <arg value="CrashSender.exe"/>
                    <arg value="/IM"/>
                    <arg value="msiexec.exe"/>
                    <arg value="/IM"/>
                    <arg value="AWR_JobScheduler.exe"/>
                    <arg value="/IM"/>
                    <arg value="mpiexec.exe"/>
                    <arg value="/IM"/>
                    <arg value="svn.exe"/>
                </exec>
            </then>
        </if>
    </target>

Replace .exes with your own. This works on windows.

-Adam Bruss

-----Original Message-----
From: Vimil Saju [mailto:vimils...@yahoo.com] 
Sent: Tuesday, February 07, 2012 10:11 PM
To: Ant Users List
Subject: Regarding exec task

Hi,

I noticed that on windows, if I use the exec task to run a batch script which 
in turn starts other processes then if kill ant then the sub-processes created 
by the batch script still continues to run. I did some research on google and 
found that the default java implementation of Process.destroy does not kill the 
child processes created by a process on windows. I also found that there are 
some third party libraries like jvnet that provide the capability of killing 
all processes created by a process on windows. So I thought of somehow 
extending the 'Execute' class of ant to use the functionality of this 3rd party 
library, but I find that its difficult if not impossible to extend this class. 
I can't find a way to provide my implementation of Process class that does 
something different when its destroy method is called. Other core tasks such as 
java task directly create an instance of the 'Execute' class which makes it 
difficult to globally change how a
process is destroyed within ant. If anyone can provide some suggestions on how 
this can be accomplished I will be very grateful.

 Currently the build scripts of my project uses the exec task to run a bunch of 
batch scripts in parallel which in turn execute sql scripts by starting off 
another process. I have written the ant script such that if any sql scripts 
fail then the ant build fails.When the build fails I notice that all the batch 
scripts have terminated as expected but the processes spawned by these batch 
scripts still continue to run.

Any help is greatly appreciated.

Thanks
Vimil

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to