[Python-checkins] cpython (merge default -> default): merge heads
benjamin.peterson
python-checkins at python.org
Thu Aug 18 20:55:50 CEST 2011
http://hg.python.org/cpython/rev/b2c6c65d59f6
changeset: 71909:b2c6c65d59f6
parent: 71908:1c7e06051288
parent: 71904:148d75d106f1
user: Benjamin Peterson <benjamin at python.org>
date: Thu Aug 18 13:55:38 2011 -0500
summary:
merge heads
files:
Lib/subprocess.py | 7 ++++++-
Misc/NEWS | 3 +++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -424,12 +424,16 @@
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 @@
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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -262,6 +262,9 @@
Library
-------
+- Issue #12650: Fix a race condition where a subprocess.Popen could leak
+ resources (FD/zombie) when killed at the wrong time.
+
- Issue #12744: Fix inefficient representation of integers between 2**31 and
2**63 on systems with a 64-bit C "long".
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list