Issue #21619: Popen objects no longer leave a zombie after exit in the with

statement if the pipe was broken.  Patch by Martin Panter.
This commit is contained in:
Serhiy Storchaka 2015-02-28 12:43:08 +02:00
parent fdde79dbf6
commit ab900c21fc
3 changed files with 24 additions and 4 deletions

View file

@ -896,10 +896,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: