ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Melissa Hao <>
Subject Re: antRunAsync and getting a background process to run indefinitely
Date Thu, 17 Apr 2003 16:33:41 GMT
Hi Bill,

I am using Solaris 5.8 and csh.  The bgtest (ant exec_output) appears to work.

I'm not sure if my setup is correct... let me describe my setup to you and you can tell me
if I'm invoking correctly.

Here's the relevant part of my build.xml:

    <property name="antRunAsync" value="/home/mhao/packages/antRunAsync/bin/antRunAsync"/>
    <exec executable="${antRunAsync}" dir="${j2ee.home}" vmlauncher="false" failonerror="true">
      <env key="ANTRUN_OUTPUT" value="oc4j2.log"/>
      <env key="ANTRUN_NOHUP" value="true" />
      <arg line=" start"/>
    </exec> is a shell script that does many things.  In the middle of the script, it starts up
a java process:

    ${JAVA_HOME}/bin/java -server -Xmx256m -jar ${J2EE_HOME}/oc4j.jar > ${J2EE_HOME}/oc4j.log
2>&1 &

I would like the following two conditions to be met:
- After processing the antRunAsync exec task, ant does not wait for the java process to complete
before going to the next task.  (This condition is currently being met.)
- The java process continues after the ant process finishes.  (This condition is not currently
being met.)

Am I setting up things correctly?


Bill Burton wrote:

> Hello,
> Melissa Hao wrote:
> > Hi,
> >
> > I'm having trouble getting the antRunAsync workaround to work exactly the way I
> >
> > I use antRunAsync to run a shell script called  The shell script is started
asynchronously, which is great.  The shell script spawns a java process in the background
(eg, "java &").  I would like this java process to continue running after the
ant process completes.  Currently, the java process stops when the ant process stops.  Is
there any way to get the java process to run indefinitely?
> I'm a little puzzled as to why this would be happening.  First, your
> script would already be run in the background by the antRunAsync
> script.  If the only thing (or the last thing) your script does is to
> start "java" in the background, the "&" isn't necessary.  Only
> if you want to start another process without waiting for that to
> complete would you need to put your java command in the background.
> Can you run the bgtest script and build file included in the archive to
> see if you have the same problem?
> Although this shouldn't be necessary, you could try redirecting all the
> standard file descriptors, i.e.
>      java </dev/null > 2>&1 &
> This is what antRunAsync does if you specify
>      <env key="ANTRUN_OUTPUT" value="some-output-file" />
> to <exec> so it shouldn't be necessary.
> What OS are you running on and what shell are you using?  Before posting
> antRunAsync, the only UNIX OS I'd tested on was Solaris 2.8.  But in
> theory, it should work the same way on all other UNIX OS's.
> -Bill
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message