summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2011-07-27 18:54:53 +0200
committerRoss Lagerwall <rosslagerwall@gmail.com>2011-07-27 18:54:53 +0200
commitd8e3901478b0ddf0b2c6cb2094a3d74f0168e4bf (patch)
treed987457f0a247746b3eef3bfdf91e1b4e6a90d12 /Lib/subprocess.py
parent5e3a19d80666b0dddef8f8a042ea1988910b61b3 (diff)
downloadcpython-git-d8e3901478b0ddf0b2c6cb2094a3d74f0168e4bf.tar.gz
Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
given as a low fd, it gets overwritten.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index ce08f83939..e92961ab75 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -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