Title: subprocess: Support close_fds on Win32
Type: Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: astrand Nosy List: astrand, georg.brandl, jongfoster, jorend, nnorwitz
Priority: normal Keywords: patch

Created on 2007-02-26 21:47 by jongfoster, last changed 2007-05-26 22:20 by astrand. This issue is now closed.

File name Uploaded Description Edit
subprocess_win32_close_handles_svn.patch jongfoster, 2007-02-26 21:47 Patch v1
subprocess_win32_close_handles_2.patch jongfoster, 2007-03-07 23:11 Patch v2 - includes docs and new test
Messages (6)
msg51972 - (view) Author: Jon Foster (jongfoster) * Date: 2007-02-26 21:47
There is an existing close_fds parameter to the subprocess.Popen() constructor that prevents FDs being copied to the child process on UNIX.  This patch makes that parameter also work on Windows (with a caveat).

Setting this parameter on Windows was explicitly prohibited by the code, because it prevents redirecting stdin/stdout/stderr.  However, the check is too restrictive; it is perfectly reasonable to set this flag if you are not redirecting anything.  That is what this patch does.

The behaviour is unchanged if you are on Windows, set this flag, and simultaneously try to redirect stdin/stdout/stderr: the call will fail with an exception.

This patch is against Python SVN trunk.

Kind regards,

Jon Foster
msg51973 - (view) Author: Jon Foster (jongfoster) * Date: 2007-03-07 23:11
I've been reading the general discussion on python-dev about patches needing documentation and tests.  So here's an updated patch that includes docs and tests.
File Added: subprocess_win32_close_handles_2.patch
msg51974 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-08 20:28
The patch looks good; unfortunately I don't have a Windows to test it, otherwise I'd apply it.
msg51975 - (view) Author: Jason Orendorff (jorend) Date: 2007-04-23 13:53
Patch looks good.  +1 (but I haven't tested it either).
msg51976 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-05-20 07:59
Peter, could you take a look at this patch?
msg51977 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2007-05-26 22:20
I've simplified the patch and applied it in revision 55604. Thanks. 
Date User Action Args
2007-02-26 21:47:16jongfostercreate