ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: [PATCH] Asynchronous execution of processes
Date Wed, 14 Nov 2001 15:48:06 GMT
On Tue, 13 Nov 2001, Jose Alberto Fernandez <j_a_fernandez@yahoo.com>
wrote:

> From: "Stefan Bodewig" <bodewig@apache.org>
> 
>> On Fri, 9 Nov 2001, Jose Alberto Fernandez
>> <j_a_fernandez@yahoo.com> wrote:
>> 
>> > There are two issues here, first what to do with IO if not
>> > redirected;
>> 
>> force it to /dev/null or NUL: or whatever - you cannot expect that
>> a detached process and Ant share the same IO streams IMHO.
> 
> Well remember that in Ken escenario which was the one I used as the
> basis for the behaviour, the asynchonous process is *supposed* to
> finish before the VM ends, so things like being able to look at the
> IO being producced are fine.

It goes against my understanding of detached processes, but I could
live with it if it is really needed - it still is dangerous for many
BuildListeners to do so.

> What happens if you use all the threads management like Execute.java
> does?  If you look at the patch, you will see that the process
> creation and lots of the other settings are performed outside of the
> deamon thread. It is only the process waitfor part and its
> surroundings that are done asynchronously.

OK, using

    public static void main(String[] args) throws Throwable {
        final Process p = Runtime.getRuntime().exec("xterm");
        Thread t = new Thread() {
                public void run() {
                    try {
                        p.waitFor();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }
            };
        t.setDaemon(true);
        t.start();
    }

it seems to work for JDK 1.3 and 1.4beta - JDK 1.1 still doesn't stop
the VM at all (and doesn't return control to the original shell) - I
guess there is a bug in the 1.1.8 VM that prevent stopping it when the
only threads left are daemon threads.

>> - but a java process [in JDK 1.4beta] keeps running, even after I
>> close the xterm.

I should add that this doesn't happen everytime I try it.

> Is it a "zombie" process by any chance?

Nope, "ps" didn't label them <defunct> like it would do on Linux.

> Any way you may know all this already.

;-)

> But why should only be your way.

Did I say so?

> We may need to rething a little and have some pseudo-task doing the
> daemon execution of the Thread.

That could help the BuildListeners, yes.

> No matter what we do, I think we will need to get a group of people
> with access to different OSs and JDKs to test is we can get some
> reliable behaviour as your tests have suggested.

Yes - I can provide Linux and FreeBSD-STABLE (not exactly stable JDK
1.2.2 only, as I try to not run in Linux emulation mode).

Stefan

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


Mime
View raw message