apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51995] New: apr_proc_create: child fds set up incorrectly if parent's stdin is closed
Date Fri, 07 Oct 2011 18:23:39 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51995

             Bug #: 51995
           Summary: apr_proc_create: child fds set up incorrectly if
                    parent's stdin is closed
           Product: APR
           Version: HEAD
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: drkp@csail.mit.edu
    Classification: Unclassified


Created attachment 27731
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27731
patch

I noticed an error which was caused by apr_proc_create setting up file
descriptors for the child process incorrectly. Specifically, the child's stdin
may fail to be connected to the pipe if the parent's stdin is closed.

What's happening is that apr allocates a pipe in the parent, and it may get
assigned fd 0 if stdin is closed. The child doesn't account for this case, so
it proceeds to dup2(0, 0) and close(0), leaving it with no stdin. The same
could happen for stdout and stderr. The attached patch will fix it.             

The way this came up for me was using Subversion to commit to a repository over
ssh, with the commit message from stdin (i.e. `svn ci -F -`). There, stdin gets
closed once the log message is read. Afterwards, it forks a child to run ssh,
but fails with a broken pipe error.

[also reported this to the dev mailing list before finding this bug tracker. On
that note, it wouldn't hurt if there were a link to the bug tracker on the APR
homepage!]

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message