Index: Modules/signalmodule.c =================================================================== --- Modules/signalmodule.c (revision 87729) +++ Modules/signalmodule.c (working copy) @@ -981,9 +981,25 @@ return 0; } +static void +_PyOS_ClearPendingSignals(void) +{ + int i; + if (!is_tripped) + return; + is_tripped = 0; + for (i = 1; i < NSIG; ++i) { + Handlers[i].tripped = 0; + } +} + 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. */ + _PyOS_ClearPendingSignals(); #ifdef WITH_THREAD PyEval_ReInitThreads(); main_thread = PyThread_get_thread_ident();