summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2013-10-20 18:31:43 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2013-10-20 18:31:43 (GMT)
commitbcd76827f4ef869454634cabefb695ff7e63967d (patch)
treee5e3e2dcfa20a44fa69263f6436f0e3345265c86 /Lib
parentf3e21ba5af43f1e8637b2752fecc3d4523056b5c (diff)
downloadcpython-bcd76827f4ef869454634cabefb695ff7e63967d.zip
cpython-bcd76827f4ef869454634cabefb695ff7e63967d.tar.gz
cpython-bcd76827f4ef869454634cabefb695ff7e63967d.tar.bz2
Issue #19309: asyncio: make waitpid() wait for all child processes, not only
those in the same process group.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/unix_events.py2
-rw-r--r--Lib/test/test_asyncio/test_events.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index a234f4f..7623f78 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -168,7 +168,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
def _sig_chld(self):
try:
try:
- pid, status = os.waitpid(0, os.WNOHANG)
+ pid, status = os.waitpid(-1, os.WNOHANG)
except ChildProcessError:
return
if pid == 0:
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index f0f4810..10ddabb 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1233,6 +1233,26 @@ class EventLoopTestsMixin:
self.loop.run_until_complete(proto.completed)
self.assertEqual(-signal.SIGTERM, proto.returncode)
+ @unittest.skipIf(sys.platform == 'win32',
+ "Don't support subprocess for Windows yet")
+ def test_subprocess_wait_no_same_group(self):
+ proto = None
+ transp = None
+
+ @tasks.coroutine
+ def connect():
+ nonlocal proto
+ # start the new process in a new session
+ transp, proto = yield from self.loop.subprocess_shell(
+ functools.partial(MySubprocessProtocol, self.loop),
+ 'exit 7', stdin=None, stdout=None, stderr=None,
+ start_new_session=True)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+
+ self.loop.run_until_complete(connect())
+ self.loop.run_until_complete(proto.completed)
+ self.assertEqual(7, proto.returncode)
+
if sys.platform == 'win32':
from asyncio import windows_events