diff options
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2017-11-03-19-11-43.bpo-30057.NCaijI.rst | 1 | ||||
-rw-r--r-- | Modules/signalmodule.c | 5 |
3 files changed, 6 insertions, 1 deletions
@@ -358,6 +358,7 @@ Vincent Delft Arnaud Delobelle Konrad Delong Erik Demaine +Jeroen Demeyer Martin Dengler John Dennis L. Peter Deutsch diff --git a/Misc/NEWS.d/next/Library/2017-11-03-19-11-43.bpo-30057.NCaijI.rst b/Misc/NEWS.d/next/Library/2017-11-03-19-11-43.bpo-30057.NCaijI.rst new file mode 100644 index 0000000..5740eb2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-11-03-19-11-43.bpo-30057.NCaijI.rst @@ -0,0 +1 @@ +Fix potential missed signal in signal.signal(). diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 0e6099f..0b9e8f1 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -462,12 +462,15 @@ signal_signal_impl(PyObject *module, int signalnum, PyObject *handler) } else func = signal_handler; + /* Check for pending signals before changing signal handler */ + if (PyErr_CheckSignals()) { + return NULL; + } if (PyOS_setsig(signalnum, func) == SIG_ERR) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } old_handler = Handlers[signalnum].func; - _Py_atomic_store_relaxed(&Handlers[signalnum].tripped, 0); Py_INCREF(handler); Handlers[signalnum].func = handler; if (old_handler != NULL) |