summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorAlex Rebert <alex@forallsecure.com>2020-01-22 18:28:31 -0500
committerGregory P. Smith <greg@krypto.org>2020-01-22 15:28:31 -0800
commitd3ae95e1e945ed20297e1c38ba43a18b7a868ab6 (patch)
tree788678084694d8dfcb2946d1ca594f1aba26f3ac /Lib/subprocess.py
parent1f0f102dec506fd06f912b74dd2be64a7fba0d3f (diff)
downloadcpython-git-d3ae95e1e945ed20297e1c38ba43a18b7a868ab6.tar.gz
bpo-35182: fix communicate() crash after child closes its pipes (GH-17020) (GH-18117)
When communicate() is called in a loop, it crashes when the child process has already closed any piped standard stream, but still continues to be running Co-authored-by: Andriy Maletsky <andriy.maletsky@gmail.com>
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 79dffd349a..26a1e69bd3 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1983,9 +1983,9 @@ class Popen(object):
with _PopenSelector() as selector:
if self.stdin and input:
selector.register(self.stdin, selectors.EVENT_WRITE)
- if self.stdout:
+ if self.stdout and not self.stdout.closed:
selector.register(self.stdout, selectors.EVENT_READ)
- if self.stderr:
+ if self.stderr and not self.stderr.closed:
selector.register(self.stderr, selectors.EVENT_READ)
while selector.get_map():