Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit c87eda0

Browse files
committed
CPython issue #19309: make waitpid() wait for processes from all groups.
1 parent e6946b9 commit c87eda0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

asyncio/unix_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _reg_sigchld(self):
168168
def _sig_chld(self):
169169
try:
170170
try:
171-
pid, status = os.waitpid(0, os.WNOHANG)
171+
pid, status = os.waitpid(-1, os.WNOHANG)
172172
except ChildProcessError:
173173
return
174174
if pid == 0:

tests/test_events.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,26 @@ def connect():
12331233
self.loop.run_until_complete(proto.completed)
12341234
self.assertEqual(-signal.SIGTERM, proto.returncode)
12351235

1236+
@unittest.skipIf(sys.platform == 'win32',
1237+
"Don't support subprocess for Windows yet")
1238+
def test_subprocess_wait_no_same_group(self):
1239+
proto = None
1240+
transp = None
1241+
1242+
@tasks.coroutine
1243+
def connect():
1244+
nonlocal proto
1245+
# start the new process in a new session
1246+
transp, proto = yield from self.loop.subprocess_shell(
1247+
functools.partial(MySubprocessProtocol, self.loop),
1248+
'exit 7', stdin=None, stdout=None, stderr=None,
1249+
start_new_session=True)
1250+
self.assertIsInstance(proto, MySubprocessProtocol)
1251+
1252+
self.loop.run_until_complete(connect())
1253+
self.loop.run_until_complete(proto.completed)
1254+
self.assertEqual(7, proto.returncode)
1255+
12361256

12371257
if sys.platform == 'win32':
12381258
from asyncio import windows_events

0 commit comments

Comments
 (0)