-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-19764: Implemented support for subprocess.Popen(close_fds=True) on Windows #1218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vstinner
merged 24 commits into
python:master
from
segevfiner:windows-subprocess-close-fds
Dec 18, 2017
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7e68016
bpo-19764: Implemented support for subprocess.Popen(close_fds=True) o…
segevfiner ad07b10
bpo-19764: Convert subprocess.Handle to int in handle_list
segevfiner 9ad94f3
bpo-19764: Fixed the handle_list warning with close_fds=True
segevfiner 24f3f39
bpo-19764: Added a test for the overriding close_fds warning
segevfiner 1eab242
bpo-19764: The warning should be emitted for handle_list and close_fd…
segevfiner 5b3cccc
Minor fixes in _winapi.c
segevfiner c84449c
bpo-19764: Addressed review comments by haypo
segevfiner f849f92
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner 0e60d28
bpo-19764: Simplified the handle_list cast to list
segevfiner 167590b
bpo-19764: Add some extra documentation about handle_list
segevfiner 59af91f
bpo-19764: Documentation update
segevfiner d4a9cdb
bpo-19764: Fixed bad reStructuredText markup
segevfiner 15424fa
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner dc1e551
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner d99af74
Merge branch 'master' into windows-subprocess-close-fds
segevfiner c63e045
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner f50ca37
Merge branch 'master' into windows-subprocess-close-fds
segevfiner 38b4526
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner 8e5d21f
bpo-19764: Fix whitespace
segevfiner 208274c
bpo-19764: Add NEWS.d entry
segevfiner 869b54c
Merge branch 'master' into windows-subprocess-close-fds
segevfiner 66b74f6
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner ba19bd8
Merge remote-tracking branch 'upstream/master' into windows-subproces…
segevfiner 3b0426e
Add Segev Finer to Misc/ACKS
segevfiner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Windows/2017-08-18-18-00-24.bpo-19764.ODpc9y.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Implement support for `subprocess.Popen(close_fds=True)` on Windows. Patch | ||
| by Segev Finer. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be convenient to be able to pass lpAttributeList in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For convenience, do you think the handles in
handle_listshould be automatically duplicated as inheritable via_make_inheritable? The problem with that is managing the lifetime of theHandleinstances. It would have to make a private copy ofSTARTUPINFO, which maybe it should be doing anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the caller would expect the handles he passes to be inherited and not a duplicate of them. The usage is to be able to selectively inherit some specific handles after all. A script using this is very likely to pass the handles he passed to
handle_listin the command line or some other IPC mechanism for the usage of the sub process, otherwise what is the point of inheriting those handles besides leaking them?Imagine a process opening some anonymous shared memory and passing that handle on the command line for a new process, making sure to properly inherit it via
handle_list. The new process will have access to the shared memory and no other additional handles which it won't even know about, unless any others are passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. I was only thinking narrowly about a user passing in a handle list without considering the context.
Can you update the docs for
handle_listto note that the handles in the list have to be made inheritable viaos.set_handle_inheritable, elseOSErrorwill be raised for the error codeERROR_INVALID_PARAMETER(87). Otherwise users may expect it to work like thepass_fdsparameter. Including the error code in the docs may help with searching, since it's such a generic error.Do you think it needs a warning that concurrent calls to
CreateProcessthat inherit all handles may inadvertently inherit the handles in this list? The race condition can only be avoided with careful design, such as by always usingPopenwith a handle list and avoiding concurrent calls toos.systemandos.spawn*or by using a lock to synchronize process creation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add some more documentation about this but I'm not really sure it's the right place for it. Feel free to suggest better wording or a better place for it.