[issue6610] Subprocess descriptor debacle
Georg Brandl ge...@python.org added the comment: Superseded by #10806. -- nosy: +georg.brandl resolution: - duplicate status: open - closed superseder: - Subprocess error if fds 0,1,2 are closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Mark Lawrence breamore...@yahoo.co.uk added the comment: The patch is small, is there any solid reason for not committing it? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Antoine Pitrou pit...@free.fr added the comment: Would the test still be correct if it didn't close stderr? I feel closing stderr is very bad from a debuggability standpoint. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Yaniv Aknin yaniv.ak...@gmail.com added the comment: I think if the test is conducted without closing stderr, it will only check that stdin/stdout are handled correctly (you could assume that if one handled stdin/stdout correctly, they did the same with stderr). However, since I've used a context manager (_NoStandardFds) to handle the closing/restoration of the standard fds, I think the benefit (fuller test coverage) outweighs the cost (potentially harder debugging if there's a problem with the test); if I'm not mistaken, the context manager should restore your fds before the default exception handler writes to stdout (at least in the parent and the child prior to exec()). n.b.: I've also created a Rietveld issue for this patch: http://codereview.appspot.com/1227041/show -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Gregory P. Smith g...@krypto.org added the comment: Thanks for the test! I'll take a look and likely commit this later. -- assignee: - gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +astrand, pitrou stage: needs patch - patch review versions: -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
Yaniv Aknin yaniv.ak...@gmail.com added the comment: It seems to me that subprocess is protected against this flaw. Python 2.x has a pure-Python implementation of the child logic (which is susceptible to an unrelated issue). Python 3.x has a C implementation which falls back to pure-Python if the former is not available. Both implementations test explicitly that they're not closing standard file descriptors after the dup2() call in the child. It is my understanding that test is sufficient, I couldn't reproduce the bug in Python, and thus I think this issue should be closed. All that said, there was no coverage in subprocess' test for this particular case (spawning a coprocess when the standard fds closed). I'm attaching a patch which adds a testcase to cover it. -- keywords: +patch nosy: +Yaniv.Aknin Added file: http://bugs.python.org/file16801/test_subprocess_with_standard_fds_closed.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6610] Subprocess descriptor debacle
New submission from Christian Heimes li...@cheimes.de: The subprocess module may suffer from a minor design flaw that is described at http://unixwiz.net/techtips/remap-pipe-fds.html under the heading Descriptor Debacle. The problem can occur under rare conditions when a subprocess is created from a Python daemon process. Proposed solution: Create a function os.duprange(*args) that takes one or more tuple pairs of file descriptors. The function takes care of the necessary order and dubbing of fds. -- components: Library (Lib) keywords: easy, needs review messages: 91118 nosy: christian.heimes priority: normal severity: normal stage: needs patch status: open title: Subprocess descriptor debacle type: resource usage versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6610 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com