diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-18 14:25:56 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-18 14:25:56 (GMT) |
commit | 6c9b35bfe2585af08ea6480294e096e2d2397fe3 (patch) | |
tree | 6ff03bbd64937ea055f5db49b505238c02cbb5a3 /Modules | |
parent | 340bb95ffd9c0947a7f6ac7f4520efada7204bc0 (diff) | |
download | cpython-6c9b35bfe2585af08ea6480294e096e2d2397fe3.zip cpython-6c9b35bfe2585af08ea6480294e096e2d2397fe3.tar.gz cpython-6c9b35bfe2585af08ea6480294e096e2d2397fe3.tar.bz2 |
Issue #11768: The signal handler of the signal module only calls
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/signalmodule.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 42d8dd8..1429770 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -164,6 +164,20 @@ checksignals_witharg(void * unused) } static void +trip_signal(int sig_num) +{ + Handlers[sig_num].tripped = 1; + if (is_tripped) + return; + /* Set is_tripped after setting .tripped, as it gets + cleared in PyErr_CheckSignals() before .tripped. */ + is_tripped = 1; + Py_AddPendingCall(checksignals_witharg, NULL); + if (wakeup_fd != -1) + write(wakeup_fd, "\0", 1); +} + +static void signal_handler(int sig_num) { int save_errno = errno; @@ -180,13 +194,7 @@ signal_handler(int sig_num) if (getpid() == main_pid) #endif { - Handlers[sig_num].tripped = 1; - /* Set is_tripped after setting .tripped, as it gets - cleared in PyErr_CheckSignals() before .tripped. */ - is_tripped = 1; - Py_AddPendingCall(checksignals_witharg, NULL); - if (wakeup_fd != -1) - write(wakeup_fd, "\0", 1); + trip_signal(sig_num); } #ifndef HAVE_SIGACTION @@ -932,9 +940,7 @@ PyErr_CheckSignals(void) void PyErr_SetInterrupt(void) { - is_tripped = 1; - Handlers[SIGINT].tripped = 1; - Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); + trip_signal(SIGINT); } void |