summaryrefslogtreecommitdiffstats
path: root/Modules/_posixsubprocess.c
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2011-07-27 05:39:27 (GMT)
committerRoss Lagerwall <rosslagerwall@gmail.com>2011-07-27 05:39:27 (GMT)
commit114f0e499d1a9c4b63a827f23fdc87937d17fa10 (patch)
tree9fdecc99c4dd9b3f9ddc3f88291990ef817ccf86 /Modules/_posixsubprocess.c
parent4d90b19373a7ed83dee2291f82167842ed738bf2 (diff)
parentd98646e43096053ee13f5a9a6af38f8c723b1aaf (diff)
downloadcpython-114f0e499d1a9c4b63a827f23fdc87937d17fa10.zip
cpython-114f0e499d1a9c4b63a827f23fdc87937d17fa10.tar.gz
cpython-114f0e499d1a9c4b63a827f23fdc87937d17fa10.tar.bz2
Issue #12607: Merge with 3.2.
Diffstat (limited to 'Modules/_posixsubprocess.c')
-rw-r--r--Modules/_posixsubprocess.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index af0d971..bc2f72c 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -69,6 +69,13 @@ static void child_exec(char *const exec_array[],
}
POSIX_CALL(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)
+ POSIX_CALL(c2pwrite = dup(c2pwrite));
+ if (errwrite == 0 || errwrite == 1)
+ POSIX_CALL(errwrite = dup(errwrite));
+
/* Dup fds for child.
dup2() removes the CLOEXEC flag but we must do it ourselves if dup2()
would be a no-op (issue #10806). */