Skip to content
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 @@ -1314,10 +1314,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