mirror of
https://github.com/python/cpython.git
synced 2025-08-29 13:15:11 +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
c8ac03d936
3 changed files with 41 additions and 3 deletions
|
@ -1419,9 +1419,6 @@ class Popen(object):
|
|||
child_exception_type = getattr(
|
||||
builtins, exception_name.decode('ascii'),
|
||||
RuntimeError)
|
||||
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