[docs] [issue25787] Add an explanation what happens with subprocess parent and child processes when signals are sent

Ian Macartney report at bugs.python.org
Wed Dec 9 03:54:06 EST 2015


Ian Macartney added the comment:

I don't have much experience with what should and shouldn't be in the python docs, however I was recently bitten by a subtlety in signal/subprocess that might be worth documenting.

Anything written to stdout in a signal handler could end up in the stdout of a process returned by Popen, if stdout gets flushed in the signal handler during a critical part of the Popen call. Furthermore, any output buffered before calling Popen could also be flushed by the signal handler, showing up in the child process's stdout. The same goes for stderr.

On 2.7.7 at least, the window where this can happen is between lines 1268-1290 in subprocess.py, where the child process has duplicated stdout, but hasn't yet called execvp.

This is a result of signal inheritance that caught me off guard, and wasn't clear to me by reading the documentation.

----------
nosy: +Ian Macartney
Added file: http://bugs.python.org/file41273/bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25787>
_______________________________________


More information about the docs mailing list