gh-77043: Make os.dup2(fd, fd, False) always remove inheritability#102148
Open
izbyshev wants to merge 2 commits intopython:mainfrom
Open
gh-77043: Make os.dup2(fd, fd, False) always remove inheritability#102148izbyshev wants to merge 2 commits intopython:mainfrom
izbyshev wants to merge 2 commits intopython:mainfrom
Conversation
Contributor
Author
|
In contrast to PR #5713, instead of adding more conditions to already unnecessarily convoluted logic of |
izbyshev
commented
Feb 22, 2023
|
|
||
| If *fd* is equal to *fd2*, the file descriptor is validated, but its | ||
| inheritability is not changed unless *inheritable* is ``False``. | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Regarding comment from PR #5713, I'm not sure if it should be versionchanged. The current mess is unintentional, so it's not like we had some clear behavior before and then we changed it.
Currently, os.dup2(fd, fd, False) behaves differently depending on the platform: * On Windows, Linux before 2.6.27, macOS, and FreeBSD it validates the fd and makes it non-inheritable. * On Solaris it validates the fd, but doesn't change its inheritability. * On modern Linux and Illumos it fails with OSError. Fix this inconsistency by making it always behave as in the first point.
6a7cce6 to
9442ad8
Compare
vstinner
reviewed
Apr 5, 2023
1123368 to
5f2f2e1
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Currently, os.dup2(fd, fd, False) behaves differently depending on the
platform:
On Windows, Linux before 2.6.27, macOS, and FreeBSD it validates the
fd and makes it non-inheritable.
On Solaris it validates the fd, but doesn't change its inheritability.
On modern Linux and Illumos it fails with OSError.
Fix this inconsistency by making it always behave as in the first point.