Guido van Rossum added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19294>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to