diff options
author | cptpcrd <31829097+cptpcrd@users.noreply.github.com> | 2021-01-20 09:05:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 15:05:51 +0100 |
commit | 7dc71c425cf6aa6a4070a418dce5d95ca435c79f (patch) | |
tree | 58d4d0fe3b680712a20b1e2c78eab629af76a1fd /Python | |
parent | Fix typos in unittest documentation (GH-24194) (diff) | |
download | cpython-7dc71c425cf6aa6a4070a418dce5d95ca435c79f.tar.gz cpython-7dc71c425cf6aa6a4070a418dce5d95ca435c79f.tar.bz2 cpython-7dc71c425cf6aa6a4070a418dce5d95ca435c79f.zip |
bpo-42780: Fix set_inheritable() for O_PATH file descriptors on Linux (GH-24172)
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 8dc90fbe2b2..f2b4681ea84 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -1234,6 +1234,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); |