From c1e46e94de38a92f98736af9a42d89c3975a9919 Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Tue, 6 Feb 2018 09:09:34 +0300 Subject: bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) Fix a rare but potential pre-exec child process deadlock in subprocess on POSIX systems when marking file descriptors inheritable on exec in the child process. This bug appears to have been introduced in 3.4 with the inheritable file descriptors support. This also changes Python/fileutils.c `set_inheritable` to use the "slow" two `fcntl` syscall path instead of the "fast" single `ioctl` syscall path when asked to be async signal safe (by way of being asked not to raise exceptions). `ioctl` is not a POSIX async-signal-safe approved function. ref: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html --- Include/fileutils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Include') diff --git a/Include/fileutils.h b/Include/fileutils.h index 21eefdef87..e4bf6d4db9 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -152,6 +152,9 @@ PyAPI_FUNC(int) _Py_get_inheritable(int fd); PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, int *atomic_flag_works); +PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, + int *atomic_flag_works); + PyAPI_FUNC(int) _Py_dup(int fd); #ifndef MS_WINDOWS -- cgit v1.2.1