summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-03 19:23:12 (GMT)
committerAntoine Pitrou <pitrou@free.fr>2017-11-03 19:23:12 (GMT)
commitea80ae04e2ec68c7e289048d3224a24b3c3fb107 (patch)
tree1122b4979bb55b2533f926903b14f6450aac1572 /Modules
parentb5f09acf0a0219cec32b7eba3acdcb573fc74ab5 (diff)
downloadcpython-ea80ae04e2ec68c7e289048d3224a24b3c3fb107.zip
cpython-ea80ae04e2ec68c7e289048d3224a24b3c3fb107.tar.gz
cpython-ea80ae04e2ec68c7e289048d3224a24b3c3fb107.tar.bz2
bpo-30057: Fix potential missed signal in signal.signal(). (GH-4258) (#4261)
Bug report and patch by Jeroen Demeyer. (cherry picked from commit f6f90ff079a22b79a58d47b6117cc8a8c7d366f3)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c5
1 files changed, 4 insertions, 1 deletions
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)