summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-28 12:45:00 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-28 12:45:00 +0200
commit9ffd6b7be22a0799f29baa1ef5440f81433672e6 (patch)
tree478525e70b85abcf935c5f4b90cdd8b7b216827f /Lib/subprocess.py
parent978bab1281030246696df198e75558d899d93602 (diff)
parent8fb246ea389a445eb9fe25566fde2e4c06284360 (diff)
downloadcpython-9ffd6b7be22a0799f29baa1ef5440f81433672e6.tar.gz
Issue #21619: Popen objects no longer leave a zombie after exit in the with
statement if the pipe was broken. Patch by Martin Panter.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 25ffefff6c..6d2c4f5587 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -892,10 +892,12 @@ class Popen(object):
self.stdout.close()
if self.stderr:
self.stderr.close()
- if self.stdin:
- self.stdin.close()
- # Wait for the process to terminate, to avoid zombies.
- self.wait()
+ try: # Flushing a BufferedWriter may raise an error
+ if self.stdin:
+ self.stdin.close()
+ finally:
+ # Wait for the process to terminate, to avoid zombies.
+ self.wait()
def __del__(self, _maxsize=sys.maxsize):
if not self._child_created: