Commit 7f1f5cc0 authored by Gregory P. Smith's avatar Gregory P. Smith

Fixes issue #9535: Fix pending signals that have been received but not yet

handled by Python to not persist after os.fork() in the child process.
parent 87710752
...@@ -9,6 +9,9 @@ What's New in Python 2.7.4 ...@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #9535: Fix pending signals that have been received but not yet
handled by Python to not persist after os.fork() in the child process.
- Issue #15001: fix segfault on "del sys.modules['__main__']". Patch by Victor - Issue #15001: fix segfault on "del sys.modules['__main__']". Patch by Victor
Stinner. Stinner.
......
...@@ -972,9 +972,25 @@ PyOS_InterruptOccurred(void) ...@@ -972,9 +972,25 @@ PyOS_InterruptOccurred(void)
return 0; return 0;
} }
static void
_clear_pending_signals(void)
{
int i;
if (!is_tripped)
return;
is_tripped = 0;
for (i = 1; i < NSIG; ++i) {
Handlers[i].tripped = 0;
}
}
void void
PyOS_AfterFork(void) PyOS_AfterFork(void)
{ {
/* Clear the signal flags after forking so that they aren't handled
* in both processes if they came in just before the fork() but before
* the interpreter had an opportunity to call the handlers. issue9535. */
_clear_pending_signals();
#ifdef WITH_THREAD #ifdef WITH_THREAD
/* PyThread_ReInitTLS() must be called early, to make sure that the TLS API /* PyThread_ReInitTLS() must be called early, to make sure that the TLS API
* can be called safely. */ * can be called safely. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment