mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
given as a low fd, it gets overwritten.
This commit is contained in:
parent
5e3a19d806
commit
d8e3901478
3 changed files with 69 additions and 0 deletions
|
@ -1148,6 +1148,14 @@ class Popen(object):
|
|||
os.close(errread)
|
||||
os.close(errpipe_read)
|
||||
|
||||
# When duping fds, if there arises a situation
|
||||
# where one of the fds is either 0, 1 or 2, it
|
||||
# is possible that it is overwritten (#12607).
|
||||
if c2pwrite == 0:
|
||||
c2pwrite = os.dup(c2pwrite)
|
||||
if errwrite == 0 or errwrite == 1:
|
||||
errwrite = os.dup(errwrite)
|
||||
|
||||
# Dup fds for child
|
||||
def _dup2(a, b):
|
||||
# dup2() removes the CLOEXEC flag but
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue