summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-08-18 13:55:38 -0500
committerBenjamin Peterson <benjamin@python.org>2011-08-18 13:55:38 -0500
commitea35d39a24281b8c3f3721ea64603035f30012a7 (patch)
tree9d60a786784c23e046c7dfd43f9e8eafffcf118e /Lib/subprocess.py
parentc07f3be4e01a7824420622a7355bf40b1685d6bc (diff)
parent558639f0c9cc507acafd0c3842a23d03b2244652 (diff)
downloadcpython-git-ea35d39a24281b8c3f3721ea64603035f30012a7.tar.gz
merge heads
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index ec417c20ea..db64588697 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -424,12 +424,16 @@ try:
except:
MAXFD = 256
+# This lists holds Popen instances for which the underlying process had not
+# exited at the time its __del__ method got called: those processes are wait()ed
+# for synchronously from _cleanup() when a new Popen object is created, to avoid
+# zombie processes.
_active = []
def _cleanup():
for inst in _active[:]:
res = inst._internal_poll(_deadstate=sys.maxsize)
- if res is not None and res >= 0:
+ if res is not None:
try:
_active.remove(inst)
except ValueError:
@@ -1272,6 +1276,7 @@ class Popen(object):
errread, errwrite,
errpipe_read, errpipe_write,
restore_signals, start_new_session, preexec_fn)
+ self._child_created = True
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)