]> granicus.if.org Git - python/commit
bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5562)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 6 Feb 2018 06:31:22 +0000 (22:31 -0800)
committerGregory P. Smith <greg@krypto.org>
Tue, 6 Feb 2018 06:31:22 +0000 (22:31 -0800)
commit2bb0bfafb0beb819b7c60d9004382ce6867847c0
tree9df4fcd2b3498091914cae3205679f66829dd8c1
parentfea0a12f6bee4a36b2c9533003e33a12c58d2d91
bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5562)

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
(cherry picked from commit c1e46e94de38a92f98736af9a42d89c3975a9919)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
Include/fileutils.h
Misc/NEWS.d/next/Library/2018-02-05-21-28-28.bpo-32777.C-wIXF.rst [new file with mode: 0644]
Modules/_posixsubprocess.c
Python/fileutils.c