diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-11-03 18:58:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-03 18:58:46 (GMT) |
commit | f6f90ff079a22b79a58d47b6117cc8a8c7d366f3 (patch) | |
tree | 1d0d62186fd0e82ececfdd384e9f684b52fa80c8 /Modules/signalmodule.c | |
parent | a7723d8b09f516a2b75837a3527b8cc7bee89fad (diff) | |
download | cpython-f6f90ff079a22b79a58d47b6117cc8a8c7d366f3.zip cpython-f6f90ff079a22b79a58d47b6117cc8a8c7d366f3.tar.gz cpython-f6f90ff079a22b79a58d47b6117cc8a8c7d366f3.tar.bz2 |
bpo-30057: Fix potential missed signal in signal.signal(). (#4258)
Bug report and patch by Jeroen Demeyer.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index d470727..1023244 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -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) |