Skip to content

bpo-44849: Fix os.set_inheritable() on FreeBSD 14 with O_PATH #27623

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 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix the :func:`os.set_inheritable` function on FreeBSD 14 for file descriptor
opened with the :data:`~os.O_PATH` flag: ignore the :data:`~errno.EBADF`
error on ``ioctl()``, fallback on the ``fcntl()`` implementation. Patch by
Victor Stinner.
7 changes: 4 additions & 3 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,11 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
return 0;
}

#ifdef __linux__
#ifdef O_PATH
if (errno == EBADF) {
// On Linux, ioctl(FIOCLEX) will fail with EBADF for O_PATH file descriptors
// Fall through to the fcntl() path
// bpo-44849: On Linux and FreeBSD, ioctl(FIOCLEX) fails with EBADF
// on O_PATH file descriptors. Fall through to the fcntl()
// implementation.
}
else
#endif
Expand Down