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.

classification
Title: subprocess.Popen: OSError: [Errno 9] Bad file descriptor
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: gagern
Priority: normal Keywords: patch

Created on 2011-08-05 10:53 by gagern, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
subprocess.patch gagern, 2011-08-05 10:53 Unit test and proposed fix.
Messages (2)
msg141653 - (view) Author: Martin von Gagern (gagern) Date: 2011-08-05 10:53
suprocess.Popen on POSIX (using _posixsubprocess Module) has a good chance of repeatedly closing the same file descriptor if the descriptor for stdin is also used for stdout and/or stderr. Only stdout and stderr are checked for equality with one another.

This breaks webbrowser.open for me, as the browser remote has all three descriptors redirected from/to /dev/null. This breaks "pydoc -p". I've taken this scenario and turned it into a unit test, which you find attached together with a proposed fix.

On my currently installed Python 3.2, the unit tests results in this traceback (and two more like it for other test classes):

ERROR: test_inouterr_fileobj (__main__.ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_subprocess.py", line 630, in test_inouterr_fileobj
    stderr = devnull)
  File "/usr/lib64/python3.2/subprocess.py", line 736, in __init__
    restore_signals, start_new_session)
  File "/usr/lib64/python3.2/subprocess.py", line 1330, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 9] Bad file descriptor
msg141654 - (view) Author: Martin von Gagern (gagern) Date: 2011-08-05 11:00
Sorry, this is a duplicate of issue #11432. Failed to find that, and also failed to realize that python is now using hg and my svn checkout might be outdated. Sorry there.
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56904
2011-08-05 11:00:18gagernsetstatus: open -> closed
resolution: duplicate
messages: + msg141654
2011-08-05 10:53:43gagerncreate