diff options
author | cptpcrd <31829097+cptpcrd@users.noreply.github.com> | 2021-01-21 10:46:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 10:46:53 (GMT) |
commit | 844ec0ba6606b60a59b7da82c54c1e646424259c (patch) | |
tree | f1643651fd0ab766ac4cb1f88e060ec1d9e995ce /Python | |
parent | ebb2f26cd8b7c0b4919e994a8e62b6e709597939 (diff) | |
download | cpython-844ec0ba6606b60a59b7da82c54c1e646424259c.zip cpython-844ec0ba6606b60a59b7da82c54c1e646424259c.tar.gz cpython-844ec0ba6606b60a59b7da82c54c1e646424259c.tar.bz2 |
bpo-42780: Fix set_inheritable() for O_PATH file descriptors on Linux (GH-24172) (GH-24277)
(cherry picked from commit 7dc71c425cf6aa6a4070a418dce5d95ca435c79f)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/fileutils.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 25516c2..fd2d5fa 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -1165,6 +1165,13 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works) return 0; } +#ifdef __linux__ + if (errno == EBADF) { + // On Linux, ioctl(FIOCLEX) will fail with EBADF for O_PATH file descriptors + // Fall through to the fcntl() path + } + else +#endif if (errno != ENOTTY && errno != EACCES) { if (raise) PyErr_SetFromErrno(PyExc_OSError); |