-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-139184: set O_CLOEXEC for master_fd when call os.forkpty #139408
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
Conversation
Signed-off-by: Manjusaka <[email protected]>
Co-authored-by: Shamil <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
Misc/NEWS.d/next/Library/2025-09-29-14-15-20.gh-issue-139184.dNl9O4.rst
Outdated
Show resolved
Hide resolved
Signed-off-by: Manjusaka <[email protected]>
|
@vstinner Thanks for your time. PTAL when you get time |
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
|
@vstinner Done |
picnixz
left a comment
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.
os.* functions are meant to mimic libc ones. As such, I'm not sure we should forcibly change inheritance (or does forkpty actually sets O_CLOEXEC as well?). Instead I would suggest one of the two:
- add an additional parameter to
forkptyto allow settingO_CLOEXECat the same time. - add a separate function (I don't have a name for it) that does it.
| if (pid == -1) { | ||
| return posix_error(); | ||
| } | ||
|
|
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 don't think you need this change.
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 like this change, it helps readability :-)
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.
Considering the function is already very compact, I don't think it helps much. But I wouldn't mind having more blank lines in the entire function to really help readability (the return is usually sufficiently clear IMO; I'm more worried about the all those ifs before actually calling forkpty)
There is PEP 446 "Make newly created file descriptors non-inheritable" which requires Python to create new file descriptors as non-inheritable. I see this change as a bugfix, but I prefer to not backport it to avoid bad surprises to users. |
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
…o manjusaka/fix-139184
Signed-off-by: Manjusaka <[email protected]>
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.
LGTM. Thanks for the update! It now looks good to me with PyErr_FormatUnraisable().
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
|
Merged, thank you. |
Uh oh!
There was an error while loading. Please reload this page.