Author gregory.p.smith
Recipients gregory.p.smith, rosslagerwall
Date 2012-10-05.07:17:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349421439.3.0.325952447162.issue16140@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-10-05 07:17:19gregory.p.smithsetrecipients: + gregory.p.smith, rosslagerwall
2012-10-05 07:17:19gregory.p.smithsetmessageid: <1349421439.3.0.325952447162.issue16140@psf.upfronthosting.co.za>
2012-10-05 07:17:19gregory.p.smithlinkissue16140 messages
2012-10-05 07:17:18gregory.p.smithcreate