summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2012-11-11 04:33:39 (GMT)
committerGregory P. Smith <greg@krypto.org>2012-11-11 04:33:39 (GMT)
commit34b14951eeb235ac0e0cbbd2ccd5d72d178dd983 (patch)
tree89af57c899c0ed161adbcc0fe3374d68d1ce9f69 /Modules/signalmodule.c
parentec6dfcffa05414e7ee29cfe88551a3d3dcdaafdc (diff)
parent9463e3ac8b230efa2f35e08859cb3db5c6d192b7 (diff)
downloadcpython-34b14951eeb235ac0e0cbbd2ccd5d72d178dd983.zip
cpython-34b14951eeb235ac0e0cbbd2ccd5d72d178dd983.tar.gz
cpython-34b14951eeb235ac0e0cbbd2ccd5d72d178dd983.tar.bz2
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.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 2eb7f29..eb89a03 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1394,9 +1394,25 @@ PyOS_InterruptOccurred(void)
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
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
/* PyThread_ReInitTLS() must be called early, to make sure that the TLS API
* can be called safely. */