Commit f6f90ff0 authored by Antoine Pitrou's avatar Antoine Pitrou Committed by GitHub

bpo-30057: Fix potential missed signal in signal.signal(). (#4258)

Bug report and patch by Jeroen Demeyer.
parent a7723d8b
......@@ -362,6 +362,7 @@ Vincent Delft
Arnaud Delobelle
Konrad Delong
Erik Demaine
Jeroen Demeyer
Martin Dengler
John Dennis
L. Peter Deutsch
......
Fix potential missed signal in signal.signal().
......@@ -461,12 +461,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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment