summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/fileutils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 397ac34..ddc0909 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);