diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-07-27 05:16:31 (GMT) |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-07-27 05:16:31 (GMT) |
commit | d98646e43096053ee13f5a9a6af38f8c723b1aaf (patch) | |
tree | 270481c64f561bd75fae76b17c7a47bca207e5f1 /Lib/subprocess.py | |
parent | 45686b472bf1f9e5ce1ef6953c4b123d271b2dc7 (diff) | |
download | cpython-d98646e43096053ee13f5a9a6af38f8c723b1aaf.zip cpython-d98646e43096053ee13f5a9a6af38f8c723b1aaf.tar.gz cpython-d98646e43096053ee13f5a9a6af38f8c723b1aaf.tar.bz2 |
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.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index ddbca6a..2d85b50 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1219,6 +1219,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 |