Bug 61153 - ExecTask closes input handle
Summary: ExecTask closes input handle
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.3
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-04 14:10 UTC by espen
Modified: 2017-06-04 18:42 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description espen 2017-06-04 14:10:02 UTC
Hi

I'm trying to solve a bug in Rundeck which uses the Apache Ant libraries. Rundeck does not compile or build any components, it runs scripts for IT administrators.

I'm running Rundeck on Windows and I'm experiencing deadslocks. I have discovered that serveral tools on Windows like PowerShell.exe does not handle a closed input handle for I/O redirection. I have also experienced this with multiple other Windows tools like cmd.exe and winrs.exe.

While debugging Rundeck i discovered that it uses Ant and creates an ExecTask object for executing a local program. ExecTask creates a Redirector object which in turn creates a PumpStreamHandler. The PumpStreamHandler however has a variable called closedwhenexhausted which causes the input thread to close the process input handle and stop the thread when no more data is available.

On Windows you cannot close the input handle until the process has completed...


Lines of code taken from StreamPumper.java. os being the output stream is the process input stream which cannot be closed until the process is done.
##############################################
        } finally {
            if (closeWhenExhausted) {
                try {
                    os.close();
                } catch (IOException e) {
                    // ignore
                }
Comment 1 espen 2017-06-04 18:42:30 UTC
I have forked the ant repository and created a pull request.
https://github.com/apache/ant/pull/34