mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fixes issue #16140: The subprocess module no longer double closes its
child subprocess.PIPE parent file descriptors on child error prior to exec(). This would lead to race conditions in multithreaded programs where another thread opened a file reusing the fd which was then closed out from beneath it by the errant second close.
This commit is contained in:
commit
c2c4cb624b
3 changed files with 42 additions and 3 deletions
|
@ -1419,9 +1419,6 @@ class Popen(object):
|
|||
child_exception_type = getattr(
|
||||
builtins, exception_name.decode('ascii'),
|
||||
SubprocessError)
|
||||
for fd in (p2cwrite, c2pread, errread):
|
||||
if fd != -1:
|
||||
os.close(fd)
|
||||
err_msg = err_msg.decode(errors="surrogatepass")
|
||||
if issubclass(child_exception_type, OSError) and hex_errno:
|
||||
errno_num = int(hex_errno, 16)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue