[issue10636] subprocess module has race condition with SIGCHLD handlers

Martin v. Löwis report at bugs.python.org
Mon Dec 6 01:33:56 CET 2010


Martin v. Löwis <martin at v.loewis.de> added the comment:

> If when it caught SIGCHLD python pushed an event onto its internal
> event loop to execute the handler, I think that would make sure it's
> deferred until after the assignment.

This is not a reasonable request. How long would you want to postpone
this? Suppose somebody writes

def foo():
    local_to_launch = subprocess.Popen("/bin/echo")
    return local_to_launch

local_to_launch = foo()

then deferring the signal until after the assignment would not help,
so the semantics of your proposed change are fuzzy.

> There might be other
> consequences of that, but I'm not familiar with the interpreter
> internals. Alternatively it could be fixed with an API change -- let
> Popen return an object before it actually launches the process, and
> have a separate start() method.

The right approach is to use sigblock/sigsetmask before creating the
process, and then again after creating it. Unfortunately, these aren't
exposed from the signal module.

----------
nosy: +loewis
title: subprocess module has race condition with SIGCHLD handlers -> subprocess module has race	condition with SIGCHLD	handlers

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


More information about the Python-bugs-list mailing list