Gregory P. Smith added the comment:

What you've described makes sense.

The file descriptors are indeed conditionally wrapped in file objects using 
io.open which could lead to a double close in the error case in a threaded 
application.  yuck.

1) The code needs to check if the fd was wrapped before calling os.close() on 
it. It could do this by checking the sys.stdin, sys.stdout and sys.stderr 
attributes respectively for each fd.

2) another option that is a little more clear code wise as it doesn't try to 
use an implied connection between the stdin/stdout/strerr attributes would be 
to _always_ wrap the fd's that this can happen to in an io object (regardless 
of if they've been assigned to the stdin/stdout/stderr attributes) and pass 
those to _execute_child.  Their .fileno() method can be used for the value to 
pass to _posixsubprocess.fork_exec().  And the os.close on those would turn 
into a close method call which won't allow double close EBADF errors.

----------

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

Reply via email to