This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients gvanrossum, ned.deily
Date 2013-10-24.14:51:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1382626292.59.0.275852670427.issue19294@psf.upfronthosting.co.za>
In-reply-to
Content
I revived my ancient PowerBook G4 just to get to the bottom of this.

The long and short of the issue seems to be that when subprocess.Popen() closes the *read* end of the stdin pipe, fstat() on the *write* end starts failing with EBADF. The exact line where the transition happens is this (aroun subprocess.py#1375):

if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
    os.close(p2cread)

This is clearly a platform bug. I also verified that the child process is still running.

Now I can't reproduce this *without* a fork+exec in the middle, so it may be that there's something magical that's done by the _posixsubprocess.fork_exec() call affecting the pipe, but before the above os.close() call the fstat() call definitely reports success, so the "closing" must be happening as a side effect of closing the other end. I'm sure there's someone at Apple with the kernel source code who can explain this, but I think we've done our due diligence.

That switching to a socketpair fixed the issue suggests that the kernel bug is related to pipes specifically.
History
Date User Action Args
2013-10-24 14:51:32gvanrossumsetrecipients: + gvanrossum, ned.deily
2013-10-24 14:51:32gvanrossumsetmessageid: <1382626292.59.0.275852670427.issue19294@psf.upfronthosting.co.za>
2013-10-24 14:51:32gvanrossumlinkissue19294 messages
2013-10-24 14:51:31gvanrossumcreate