summaryrefslogtreecommitdiffstats
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-08-06 13:15:10 (GMT)
committerGitHub <noreply@github.com>2021-08-06 13:15:10 (GMT)
commitc24896c0e3b32c8a9f614ef51366007b67d5c665 (patch)
tree912b10841274a62ab0b65e0e86e6a892edfcfd14 /Python/fileutils.c
parent15d3c14df32a35ac69898a7852115722e30d7857 (diff)
downloadcpython-c24896c0e3b32c8a9f614ef51366007b67d5c665.zip
cpython-c24896c0e3b32c8a9f614ef51366007b67d5c665.tar.gz
cpython-c24896c0e3b32c8a9f614ef51366007b67d5c665.tar.bz2
bpo-44849: Fix os.set_inheritable() on FreeBSD 14 with O_PATH (GH-27623)
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.
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index a8fab00..e8a7eda 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -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