mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42780: Fix set_inheritable() for O_PATH file descriptors on Linux (GH-24172) (GH-24278)
(cherry picked from commit 7dc71c425c
)
This commit is contained in:
parent
0654c4c4cc
commit
6893523bed
3 changed files with 35 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue