You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Vimil Saju <vi...@yahoo.com> on 2012/02/08 05:10:36 UTC

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

RE: Regarding exec task

Posted by Adam Bruss <ab...@awrcorp.com>.
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: abruss@awrcorp.com
W: http://www.awrcorp.com

-----Original Message-----
From: Vimil Saju [mailto:vimilsaju@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 <ab...@awrcorp.com>
To: Ant Users List <us...@ant.apache.org>; Vimil Saju <vi...@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:vimilsaju@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

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


Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
This sounds good, but won't it kill processes that wasn't started by my script too?


________________________________
 From: Adam Bruss <ab...@awrcorp.com>
To: Ant Users List <us...@ant.apache.org>; Vimil Saju <vi...@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:vimilsaju@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

RE: Regarding exec task

Posted by Adam Bruss <ab...@awrcorp.com>.
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:vimilsaju@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
No problem, In the mean time I will use a locally modified version of ant for the build.

Thanks
Vimil


________________________________
 From: Stefan Bodewig <bo...@apache.org>
To: dev@ant.apache.org 
Sent: Wednesday, February 22, 2012 8:35 AM
Subject: Re: Regarding exec task
 
On 2012-02-21, Vimil Saju wrote:

> When you get a chance could you look at the patch for the below issue?

That's Bugzilla issue 52706, right?  Unfortunately I didn't have the
time to review it, yet.

> I really would like to see this make into ant 1.8.3 release.

If it hadn't been for the regression 1.8.3 would be out there already.
I really only want to address the single issue, cut the release and then
go on after that.

I understand this may be unsatisfying and can only promise to look into
it soon after preparing the release so it'll end up in whatever comes
after 1.8.3.

Sorry

        Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

Re: Regarding exec task

Posted by Stefan Bodewig <bo...@apache.org>.
On 2012-02-21, Vimil Saju wrote:

> When you get a chance could you look at the patch for the below issue?

That's Bugzilla issue 52706, right?  Unfortunately I didn't have the
time to review it, yet.

> I really would like to see this make into ant 1.8.3 release.

If it hadn't been for the regression 1.8.3 would be out there already.
I really only want to address the single issue, cut the release and then
go on after that.

I understand this may be unsatisfying and can only promise to look into
it soon after preparing the release so it'll end up in whatever comes
after 1.8.3.

Sorry

        Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
Stefan,

When you get a chance could you look at the patch for the below issue? I really would like to see this make into ant 1.8.3 release.

Thanks
Vimil


________________________________
 From: Vimil Saju <vi...@yahoo.com>
To: Ant Developers List <de...@ant.apache.org> 
Sent: Friday, February 17, 2012 8:25 PM
Subject: Re: Regarding exec task
 

Hi Stefan,

I have attached a patch containing the changes I made to Execute java class.�
What I have basically done is move the code that initializes the CommandLauncher from the Execute class to to the CommandLauncher class. I have made CommandLauncher class public and all the subclasses of it public too. �I have added two static methods�
getVMLauncher and getShellLauncher to the CommandLauncher class. These methods take a Project object as parameter and check if a reference to an existing CommandLauncher is present in the project. If present then that instance is returned. Otherwise the method checks if a system property containing the name of the launcher class has been set. If so then an instance of that class is created and returned, otherwise the default launcher is returned. I have also added setVMLauncher and setShellLauncher methods that add reference to a given CommandLauncher instance to the project.�

I have modified the Execute class to use these two methods to get the reference of the CommandLauncher class. I have also created a CommanLauncherTask class similar to the PropertyHelperTask that takes an instance of any CommandLauncher class and adds a reference to it to the project. �

Could you take a look at the patch and let me know if any other changes need to be made.

Thanks
Vimil�


________________________________
 From: Stefan Bodewig <bo...@apache.org>
To: dev@ant.apache.org 
Sent: Tuesday, February 14, 2012 5:45 AM
Subject: Re: Regarding exec task
 
On 2012-02-14, Vimil Saju wrote:

> Your help is very much appreciated. Would using a custom
> CommandLauncher make it possible for all the built-in ant tasks that
> support fork attribute to use it.�

Right now Execute uses a static CommandLauncher instance which is
initialize inside the static initializer ("class constructor").
CommandLauncher's responsibility is tro create the Process instances.

We don't have a way to make Execute use a different CommandLauncher, but
if there was (like using the ProcessHelper you describe) then it would
be used by all Execute instances - or we could make it so.

> I was thinking of an approach similar to how ant allows property
> expansion to be customized. By just adding our own custom
> PropertyHelper we can change how properties are expanded globally.� If
> we have something like that for processes too, it would be great.

>
 I'd like to write a patch for this if possible, but I'd like to know
> the best way to implement it, without breaking anything else.

That's great.

> My idea was to provide something like ProcessHelper class that can be
> stored as a reference in the project. The Execute class then calls
> this class to get an appropriate Process implementation.

I'm not sure about the name ProcessHelper when CommandLauncher is
already there, but I'm not good at names either.

One thing you must keep in mind is Execute may not have access to a
Project instance at all - it may know about one if setAntRun has been
used, but using that is somewhat optional.� Also some methods in Execute
are static and don't provide a Project.� There need to be usable
defaults for this case.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
Hi Stefan,

I have attached a patch containing the changes I made to Execute java class.�
What I have basically done is move the code that initializes the CommandLauncher from the Execute class to to the CommandLauncher class. I have made CommandLauncher class public and all the subclasses of it public too. �I have added two static methods�
getVMLauncher and getShellLauncher to the CommandLauncher class. These methods take a Project object as parameter and check if a reference to an existing CommandLauncher is present in the project. If present then that instance is returned. Otherwise the method checks if a system property containing the name of the launcher class has been set. If so then an instance of that class is created and returned, otherwise the default launcher is returned. I have also added setVMLauncher and setShellLauncher methods that add reference to a given CommandLauncher instance to the project.�

I have modified the Execute class to use these two methods to get the reference of the CommandLauncher class. I have also created a CommanLauncherTask class similar to the PropertyHelperTask that takes an instance of any CommandLauncher class and adds a reference to it to the project. �

Could you take a look at the patch and let me know if any other changes need to be made.

Thanks
Vimil�


________________________________
 From: Stefan Bodewig <bo...@apache.org>
To: dev@ant.apache.org 
Sent: Tuesday, February 14, 2012 5:45 AM
Subject: Re: Regarding exec task
 
On 2012-02-14, Vimil Saju wrote:

> Your help is very much appreciated. Would using a custom
> CommandLauncher make it possible for all the built-in ant tasks that
> support fork attribute to use it.�

Right now Execute uses a static CommandLauncher instance which is
initialize inside the static initializer ("class constructor").
CommandLauncher's responsibility is tro create the Process instances.

We don't have a way to make Execute use a different CommandLauncher, but
if there was (like using the ProcessHelper you describe) then it would
be used by all Execute instances - or we could make it so.

> I was thinking of an approach similar to how ant allows property
> expansion to be customized. By just adding our own custom
> PropertyHelper we can change how properties are expanded globally.� If
> we have something like that for processes too, it would be great.

> I'd like to write a patch for this if possible, but I'd like to know
> the best way to implement it, without breaking anything else.

That's great.

> My idea was to provide something like ProcessHelper class that can be
> stored as a reference in the project. The Execute class then calls
> this class to get an appropriate Process implementation.

I'm not sure about the name ProcessHelper when CommandLauncher is
already there, but I'm not good at names either.

One thing you must keep in mind is Execute may not have access to a
Project instance at all - it may know about one if setAntRun has been
used, but using that is somewhat optional.� Also some methods in Execute
are static and don't provide a Project.� There need to be usable
defaults for this case.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

Re: Regarding exec task

Posted by Stefan Bodewig <bo...@apache.org>.
On 2012-02-14, Vimil Saju wrote:

> Your help is very much appreciated. Would using a custom
> CommandLauncher make it possible for all the built-in ant tasks that
> support fork attribute to use it. 

Right now Execute uses a static CommandLauncher instance which is
initialize inside the static initializer ("class constructor").
CommandLauncher's responsibility is tro create the Process instances.

We don't have a way to make Execute use a different CommandLauncher, but
if there was (like using the ProcessHelper you describe) then it would
be used by all Execute instances - or we could make it so.

> I was thinking of an approach similar to how ant allows property
> expansion to be customized. By just adding our own custom
> PropertyHelper we can change how properties are expanded globally.  If
> we have something like that for processes too, it would be great.

> I'd like to write a patch for this if possible, but I'd like to know
> the best way to implement it, without breaking anything else.

That's great.

> My idea was to provide something like ProcessHelper class that can be
> stored as a reference in the project. The Execute class then calls
> this class to get an appropriate Process implementation.

I'm not sure about the name ProcessHelper when CommandLauncher is
already there, but I'm not good at names either.

One thing you must keep in mind is Execute may not have access to a
Project instance at all - it may know about one if setAntRun has been
used, but using that is somewhat optional.  Also some methods in Execute
are static and don't provide a Project.  There need to be usable
defaults for this case.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
Thanks Stefan, 

Your help is very much appreciated. Would using a custom CommandLauncher make it possible for all the built-in ant tasks that support fork attribute to use it. 
I was thinking of an approach similar to how ant allows property expansion to be customized. By just adding our own custom PropertyHelper we can change how properties are expanded globally.
If we have something like that for processes too, it would be great.  

I'd like to write a patch for this if possible, but I'd like to know the best way to implement it, without breaking anything else. My idea was to provide something like ProcessHelper class that can be stored as a reference in the project. The Execute class then calls this class to get an appropriate Process implementation. This ProcessHelper class should then have the ability to provide a default Process implementation as well as a mechanism to delegate process creation to a user-defined class. 

Thanks again. 
Vimil


________________________________
 From: Stefan Bodewig <bo...@apache.org>
To: dev@ant.apache.org 
Sent: Tuesday, February 14, 2012 4:46 AM
Subject: Re: Regarding exec task
 
On 2012-02-12, Vimil Saju wrote:

> 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.

It has certainly not been designed for this, no.

> Is it possible to make the Execute class in ant extensible so that it
> becomes possible to plugin our own implementation of Process class.

If you had a way to provide your own CommandLauncher then you could wrap
Execute's default choice with your own implementation and return a
Process class of your liking.  This is not possible today, but I'm
testing whether this would be enough for you.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

Re: Regarding exec task

Posted by Stefan Bodewig <bo...@apache.org>.
On 2012-02-12, Vimil Saju wrote:

> 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.

It has certainly not been designed for this, no.

> Is it possible to make the Execute class in ant extensible so that it
> becomes possible to plugin our own implementation of Process class.

If you had a way to provide your own CommandLauncher then you could wrap
Execute's default choice with your own implementation and return a
Process class of your liking.  This is not possible today, but I'm
testing whether this would be enough for you.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.
I could do that, but I will have to copy all the code from the execute class that does stuff like adding hooks to destroy processes when the jvm exits, parsing command-line arguments etc, when all I want to do is override how processes created by ant are destroyed. Besides even if I were to create another exec task, none of the built-in ant tasks that support the fork attribute (like java task) are going to call my class to create processes. From looking at the ant source code, I see that all tasks use to the 'Execute' class for process creation. I was thinking if the Execute class allowed the process creation code to be overridden then I could provide a new process destruction mechanism and it will be invoked by all the built-in tasks that support the fork attribute. 

From: wolfgang häfelinger <wh...@gmail.com>
To: Ant Developers List <de...@ant.apache.org>; Vimil Saju <vi...@yahoo.com> 
Sent: Sunday, February 12, 2012 7:32 AM
Subject: Re: Regarding exec task
 
> Is it possible to make the Execute class in ant extensible so that it becomes possible to plugin our own implementation of Process class.

Implement your own ueber-exec taks which uses default exec class when
not-on windows and otherwise makes use of your own jvnet-process exec
task.

On Sun, Feb 12, 2012 at 3:29 PM, Vimil Saju <vi...@yahoo.com> wrote:
>
>
>
>
> 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 forked process is destroyed within ant.
>
> Is it possible to make the Execute class in ant extensible so that it becomes possible to plugin our own implementation of Process class.
>
>
> Thanks
>
> Vimil



-- 
Wolfgang Häfelinger

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

Re: Regarding exec task

Posted by wolfgang häfelinger <wh...@gmail.com>.
> Is it possible to make the Execute class in ant extensible so that it becomes possible to plugin our own implementation of Process class.

Implement your own ueber-exec taks which uses default exec class when
not-on windows and otherwise makes use of your own jvnet-process exec
task.

On Sun, Feb 12, 2012 at 3:29 PM, Vimil Saju <vi...@yahoo.com> wrote:
>
>
>
>
> 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 forked process is destroyed within ant.
>
> Is it possible to make the Execute class in ant extensible so that it becomes possible to plugin our own implementation of Process class.
>
>
> Thanks
>
> Vimil



-- 
Wolfgang Häfelinger

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Regarding exec task

Posted by Vimil Saju <vi...@yahoo.com>.



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 forked process is destroyed within ant.

Is it possible to make the Execute class in ant extensible so that it becomes possible to plugin our own implementation of Process class.


Thanks

Vimil