[Python-checkins] cpython (merge 3.3 -> default): Fixes issue #9535: Fix pending signals that have been received but not

gregory.p.smith python-checkins at python.org
Sun Nov 11 05:34:53 CET 2012


http://hg.python.org/cpython/rev/41280973921a
changeset: 80360:41280973921a
parent: 80356:d63c751e9f01
parent: 80359:c7d6cd3c27b9
user: Gregory P. Smith <greg at krypto.org>
date: Sat Nov 10 20:34:41 2012 -0800
summary:
 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.
files:
 Misc/NEWS | 3 +++
 Modules/signalmodule.c | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 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
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1389,9 +1389,25 @@
 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. */
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /