Title: Ignored SIGCHLD causes asyncio.Process.wait to hang forever
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.7, Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: asyncio.create_subprocess_exec() only works with main event loop
View: 35621
Assigned To: Nosy List: asvetlov, rogpeppe, yselivanov
Priority: normal Keywords:

Created on 2017-11-22 18:32 by rogpeppe, last changed 2019-06-02 11:16 by asvetlov. This issue is now closed.

File name Uploaded Description Edit
tst.c rogpeppe, 2017-11-22 18:32 C code that calls python with ignored SIGCHLD
Messages (3)
msg306745 - (view) Author: rogpeppe (rogpeppe) * Date: 2017-11-22 18:32
If some parent process has disabled SIGCHLD, that signal is inherited and stops that signal being delivered, which means that asyncio.Process.wait will never complete.

As an example, the plan9port terminal window, 9term, ( does this, and hence causes async Python processes to hang forever.

Python should probably code defensively against this and ensure that SIGCHLD is enabled regardless. Attached is some C code that demonstrates the issue when the following python code is saved to "".

    #!/usr/bin/env python3
    import asyncio
    async def do_exec():
        cmd = ['echo', 'hello, world']
        process = await asyncio.create_subprocess_exec(*cmd, env={})
        await process.wait()

demonstration of the issue.
msg308898 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2017-12-21 19:48
Thank for bug report.
Do you know other widespread tools with this problem? 
plan9port sounds too esoteric to me.
msg344278 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-06-02 11:16
#35621 fixes the problem for default ThreadedChildWatcher
Date User Action Args
2019-06-02 11:16:29asvetlovsetstatus: open -> closed
superseder: asyncio.create_subprocess_exec() only works with main event loop
messages: + msg344278

resolution: duplicate
stage: resolved
2017-12-21 19:48:19asvetlovsetnosy: + asvetlov

messages: + msg308898
versions: + Python 3.6, Python 3.7, - Python 3.5
2017-11-22 18:32:12rogpeppecreate