diff options
author | Gregory P. Smith <greg@krypto.org> | 2012-11-10 20:38:17 -0800 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2012-11-10 20:38:17 -0800 |
commit | c1ce93a4ab0c6e1ed5e7e013789a669871b2257d (patch) | |
tree | 7b0cc40c663fac25a2954520c35c6cf24323837e | |
parent | acfdfdafa202b634bc9f9ca5d3aa52e0aeb04e73 (diff) | |
download | cpython-git-c1ce93a4ab0c6e1ed5e7e013789a669871b2257d.tar.gz |
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/NEWS | 3 | ||||
-rw-r--r-- | Modules/signalmodule.c | 16 |
2 files changed, 19 insertions, 0 deletions
@@ -9,6 +9,9 @@ What's New in Python 2.7.4 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 Stinner. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 908c2ee994..f706a8fd8f 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -972,9 +972,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. */ |