[issue5313] multiprocessing.process using os.close(sys.stdin.fileno) instead of sys.stdin.close()
OG7
report at bugs.python.org
Fri Jun 19 17:55:26 CEST 2009
OG7 <onyxg7 at users.sourceforge.net> added the comment:
Please do this:
--- a/multiprocessing/process.py
+++ b/multiprocessing/process.py
@@ -225,7 +225,8 @@ class Process(object):
self._children = set()
self._counter = itertools.count(1)
try:
- os.close(sys.stdin.fileno())
+ sys.stdin.close()
+ sys.stdin = open(os.devnull)
except (OSError, ValueError):
pass
_current_process = self
One shouldn't close the fileno after the file has been closed. The
stdlib raises an error, and the open(os.devnull) won't be reached. If no
error was thrown, it would be worse. This would be closing a fileno that
doesn't belong to sys.stdin anymore and may be used somewhere else.
The open(os.devnull) bit is both so that no one tries to do anything
with the old stdin anymore, and to let applications attempt to read from
stdin without an IOError.
----------
Added file: http://bugs.python.org/file14320/0001-Fix-issue-5313.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5313>
_______________________________________
More information about the Python-bugs-list
mailing list