]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19309: asyncio: make waitpid() wait for all child processes, not only
authorCharles-François Natali <cf.natali@gmail.com>
Sun, 20 Oct 2013 18:31:43 +0000 (20:31 +0200)
committerCharles-François Natali <cf.natali@gmail.com>
Sun, 20 Oct 2013 18:31:43 +0000 (20:31 +0200)
those in the same process group.

Lib/asyncio/unix_events.py
Lib/test/test_asyncio/test_events.py

index a234f4fac13a190706fb2ab30563c0bab8dd0485..7623f789d312b96095d13ee19190898896cab542 100644 (file)
@@ -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:
index f0f4810f6752e498bf190048192c41e810d85bce..10ddabb8ed437e54102f460bfe50119b4864779f 100644 (file)
@@ -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