diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-10-19 19:15:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 19:15:29 (GMT) |
commit | 67e10be3fee7c69d4ece26e75a0b7a84dab68ce5 (patch) | |
tree | 1e4b62ac4e73adc9026389ef3a9c582ea2f3b103 /Python/fileutils.c | |
parent | 7f70ba36706219181546c05363097f732827a081 (diff) | |
download | cpython-67e10be3fee7c69d4ece26e75a0b7a84dab68ce5.zip cpython-67e10be3fee7c69d4ece26e75a0b7a84dab68ce5.tar.gz cpython-67e10be3fee7c69d4ece26e75a0b7a84dab68ce5.tar.bz2 |
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 c24896c0e3b32c8a9f614ef51366007b67d5c665)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r-- | Python/fileutils.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 3e1311c..f0bdd9c 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -1205,10 +1205,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 |