diff options
author | Vladimir Matveev <v2matveev@outlook.com> | 2019-01-08 09:58:25 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-01-08 09:58:25 (GMT) |
commit | c24c6c2c9357da99961bf257078240529181daf3 (patch) | |
tree | 552b9c627f21770d971d26f0d7d38e8a1b58ea02 /Modules/signalmodule.c | |
parent | e61cc481e02b758c8d8289163102c236d0658a55 (diff) | |
download | cpython-c24c6c2c9357da99961bf257078240529181daf3.zip cpython-c24c6c2c9357da99961bf257078240529181daf3.tar.gz cpython-c24c6c2c9357da99961bf257078240529181daf3.tar.bz2 |
bpo-35568: add 'raise_signal' function (GH-11335)
As in title, expose C `raise` function as `raise_function` in `signal` module. Also drop existing `raise_signal` in `_testcapi` module and replace all usages with new function.
https://bugs.python.org/issue35568
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 52ab4e9..4f8f71a 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -390,6 +390,31 @@ signal_pause_impl(PyObject *module) #endif +/*[clinic input] +signal.raise_signal + + signalnum: int + / + +Send a signal to the executing process. +[clinic start generated code]*/ + +static PyObject * +signal_raise_signal_impl(PyObject *module, int signalnum) +/*[clinic end generated code: output=e2b014220aa6111d input=e90c0f9a42358de6]*/ +{ + int err; + Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH + err = raise(signalnum); + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS + + if (err) { + return PyErr_SetFromErrno(PyExc_OSError); + } + Py_RETURN_NONE; +} /*[clinic input] signal.signal @@ -1208,6 +1233,7 @@ static PyMethodDef signal_methods[] = { SIGNAL_SETITIMER_METHODDEF SIGNAL_GETITIMER_METHODDEF SIGNAL_SIGNAL_METHODDEF + SIGNAL_RAISE_SIGNAL_METHODDEF SIGNAL_STRSIGNAL_METHODDEF SIGNAL_GETSIGNAL_METHODDEF {"set_wakeup_fd", (PyCFunction)(void(*)(void))signal_set_wakeup_fd, METH_VARARGS | METH_KEYWORDS, set_wakeup_fd_doc}, |