Skip to content

Commit 67e10be

Browse files
bpo-44849: Fix os.set_inheritable() on FreeBSD 14 with O_PATH (GH-27623) (GH-28978)
Fix the os.set_inheritable() function on FreeBSD 14 for file descriptor opened with the O_PATH flag: ignore the EBADF error on ioctl(), fallback on the fcntl() implementation. (cherry picked from commit c24896c) Co-authored-by: Victor Stinner <[email protected]>
1 parent 7f70ba3 commit 67e10be

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix the :func:`os.set_inheritable` function on FreeBSD 14 for file descriptor
2+
opened with the :data:`~os.O_PATH` flag: ignore the :data:`~errno.EBADF`
3+
error on ``ioctl()``, fallback on the ``fcntl()`` implementation. Patch by
4+
Victor Stinner.

Python/fileutils.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,10 +1205,11 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
12051205
return 0;
12061206
}
12071207

1208-
#ifdef __linux__
1208+
#ifdef O_PATH
12091209
if (errno == EBADF) {
1210-
// On Linux, ioctl(FIOCLEX) will fail with EBADF for O_PATH file descriptors
1211-
// Fall through to the fcntl() path
1210+
// bpo-44849: On Linux and FreeBSD, ioctl(FIOCLEX) fails with EBADF
1211+
// on O_PATH file descriptors. Fall through to the fcntl()
1212+
// implementation.
12121213
}
12131214
else
12141215
#endif

0 commit comments

Comments
 (0)