Skip to content

bpo-45915: use fcntl(fd, F_GETFD) in is_valid_fd() (GH-29821) #29821

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
merged 2 commits into from
Nov 28, 2021

Conversation

tiran
Copy link
Member

@tiran tiran commented Nov 28, 2021

Signed-off-by: Christian Heimes [email protected]

https://bugs.python.org/issue45915

@tiran tiran requested a review from vstinner November 28, 2021 10:29
@tiran tiran added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 28, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @tiran for commit 0d3a911 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 28, 2021
@@ -2139,6 +2145,12 @@ is_valid_fd(int fd)
if (fd < 0) {
return 0;
}
#ifdef F_GETFD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS also supports F_GETFD flag also.
On my macOS, all tests are passed with changes to use F_GETFD.

bpo-30225: On macOS Tiger, when stdout is redirected to a pipe and the other

macOS Tiger is 10.4, we provide installers for 10.9+ nowadays.
https://www.python.org/downloads/release/python-3100/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would like to suggest changing the code to support macOS also.

@tiran tiran force-pushed the bpo-45915-valid-fd branch from c93fa66 to 70ca98b Compare November 28, 2021 13:38
Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tiran tiran changed the title bpo-45915: use fcntl(fd, F_GETFD) in is_valid_fd() bpo-45915: use fcntl(fd, F_GETFD) in is_valid_fd() (GH-29821) Nov 28, 2021
@tiran tiran merged commit f87ea03 into python:main Nov 28, 2021
@tiran tiran deleted the bpo-45915-valid-fd branch November 28, 2021 18:40
@vstinner
Copy link
Member

 #if defined(F_GETFD) && (defined(__linux__) || defined(__APPLE__) || defined(MS_WINDOWS))

Why restricting the change to a few plaforms if it's faster?

@tiran
Copy link
Member Author

tiran commented Nov 29, 2021

I have no means to test this on other platforms. I know it works on Linux and Dong-hee told me it works on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants