ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: Stopping a process identified by name
Date Wed, 05 Dec 2007 10:40:38 GMT
Stepan Mishura wrote:
> On 11/28/07, Agarkar, M (Milind) <Milind.Agarkar@rabobank.com> wrote:
>> Thanks Jan.
>> Any idea about how to trap a PID on-the-fly ? It would be a script to run automatically.
>>
> 
> In snapshot testing we use the next targets to find and kill hung VMs
> after a suite run.

that's cute. I'd probably just use killall, though its important to get 
that pattern right or bad things happen

For ant1.8 I've been putting together a functional test task, <funtest> 
that starts something in one thread, provided a condition to block a 
test thread, runs the tests and then finally some teardown/reporting 
tasks.  This may make the problem you are trying to solve easier

> 
>     <target name="clear-processes"
>             if="need.processes.cleanup"
>             depends="-init-clear-processes">
> 
>         <echo>PROCESSES: ${proccess}</echo>
>         <exec executable="kill">
>             <arg line="${proccess}" />
>         </exec>
>     </target>
> 
>     <target name="-init-clear-processes" unless="is.windows">
>         <exec executable="ps">
>             <arg value="a" />
>             <redirector outputproperty="proccess">
>                 <outputfilterchain>
>                     <!-- select only snapshot vm -->
>                     <linecontainsregexp>
>                         <regexp pattern="\s${jvm.location}\s" />
>                     </linecontainsregexp>
>                     <!-- get processes pids -->
>                     <tokenfilter>
>                         <replaceregex pattern="^\s*(\d+).*" replace="\1 " />
>                     </tokenfilter>
>                     <striplinebreaks />
>                 </outputfilterchain>
>             </redirector>
>         </exec>
> 
>         <condition property="need.processes.cleanup">
>             <and>
>                 <istrue value="${do.processes.cleanup}" />
>                 <length string="${proccess}"
>                         trim="true"
>                         when="greater"
>                         length="0" />
>             </and>
>         </condition>
>     </target>
> 
> 


-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Mime
View raw message