ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 5003] exec task does not return after executed command finished on Windows only
Date Fri, 12 Apr 2013 17:48:28 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=5003

--- Comment #38 from James Wartell <jameswartell@gmail.com> ---
I had something like this in some of my code.

I found process.join() was returning, but my joins on the workers reading the
input streams were not. 

you could assume if the process has been dead, or has been dead a certain
amount of time, you no longer care about the data on the streams. I ran into
something like this when killing an external process. In my case, the choice is
easy. I am forcibly terminating it. I don't care about the streams. Basically
you get a reference to the streams while the process is still alive. And then
at any point after it's dead, (or should be) you close the streams. This worked
like a charm for me. I could do this where I join the process as well, instead
of where I kill it.

So....


    OutputStream outputStream = process.getOutputStream();
    InputStream inputStream = process.getInputStream();
    InputStream errorStream = process.getErrorStream();

    process.destroy();


    try
    {
        outputStream.flush();
    }
    catch(IOException e)
    {
    }

    try
    {
        outputStream.close();
    }
    catch(IOException e)
    {
    }

    try
    {
        errorStream.close();
    }
    catch(IOException e)
    {
    }

    try
    {
        inputStream.close();
    }
    catch(IOException e)
    {
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.

Mime
View raw message