summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2012-11-11 04:34:41 (GMT)
committerGregory P. Smith <greg@krypto.org>2012-11-11 04:34:41 (GMT)
commit0b83224c0ddcb87e2ea139aba5a1e33d70cc9945 (patch)
treeaec24c23dbb98593c9ff738d188564231feb5de3
parent9c40022e38ba250c84382e4a4e68a05c0024559d (diff)
parent34b14951eeb235ac0e0cbbd2ccd5d72d178dd983 (diff)
downloadcpython-0b83224c0ddcb87e2ea139aba5a1e33d70cc9945.zip
cpython-0b83224c0ddcb87e2ea139aba5a1e33d70cc9945.tar.gz
cpython-0b83224c0ddcb87e2ea139aba5a1e33d70cc9945.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.
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/signalmodule.c16
2 files changed, 19 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 6d14ecf..c289cd4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
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 #14794: Fix slice.indices to return correct results for huge values,
rather than raising OverflowError.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index f7ce48c..d633301 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1389,9 +1389,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. */