8000 bpo-23325: Turn signal.SIG_DFL and signal.SIG_IGN into functions. by serhiy-storchaka · Pull Request #8920 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-23325: Turn signal.SIG_DFL and signal.SIG_IGN into functions. #8920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into signal-std-handlers
  • Loading branch information
serhiy-storchaka committed Jun 28, 2020
commit af73646e6d1239b07351a2e7d10faeaeca817d40
1 change: 1 addition & 0 deletions Lib/test/test_signal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import errno
import os
import pickle
import random
Expand Down
68 changes: 67 additions & 1 deletion Modules/clinic/signalmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 67 additions & 12 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,19 +1261,74 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
#endif /* #if defined(HAVE_PTHREAD_KILL) */


/*[clinic input]
signal.SIG_DFL
signalnum: int
frame: object
/

Standard signal handler used to refer to the system default handler.
[clinic start generated code]*/

static PyObject *
signal_sig_const(PyObject *self, PyObject *args)
signal_SIG_DFL_impl(PyObject *module, int signalnum, PyObject *frame)
/*[clinic end generated code: output=7293f25d5f7a3415 input=9df97af30cd58214]*/
{
PyErr_SetString(PyExc_TypeError,
"standard handler can't be called directly");
"system default handler can't be called directly");
return NULL;
}

PyDoc_STRVAR(signal_SIG_DFL_doc,
"Standard signal handler used to refer to the system default handler.");

PyDoc_STRVAR(signal_SIG_IGN_doc,
"Standard signal handler used to ignore the given signal.");
/*[clinic input]
signal.SIG_IGN
signalnum: int
frame: object
/

Standard signal handler used to ignore the given signal.
[clinic start generated code]*/

static PyObject *
signal_SIG_IGN_impl(PyObject *module, int signalnum, PyObject *frame)
/*[clinic end generated code: output=8b52aad79325460a input=1b49e704cb42377a]*/
{
Py_RETURN_NONE;
}


#if defined(__linux__) && defined(__NR_pidfd_send_signal)
/*[clinic input]
signal.pidfd_send_signal

pidfd: int
signalnum: int
siginfo: object = None
flags: int = 0
/

Send a signal to a process referred to by a pid file descriptor.
[clinic start generated code]*/

static PyObject *
signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum,
PyObject *siginfo, int flags)
/*[clinic end generated code: output=2d59f04a75d9cbdf input=2a6543a1f4ac2000]*/

{
if (siginfo != Py_None) {
PyErr_SetString(PyExc_TypeError, "siginfo must be None");
return NULL;
}
if (syscall(__NR_pidfd_send_signal, pidfd, signalnum, NULL, flags) < 0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
Py_RETURN_NONE;
}
#endif



/* List of functions defined in the module -- some of the methoddefs are< 9D87 /span>
defined to nothing if the corresponding C function is not available. */
Expand All @@ -1299,8 +1354,8 @@ static PyMethodDef signal_methods[] = {
#if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
SIGNAL_VALID_SIGNALS_METHODDEF
#endif
{"SIG_DFL", signal_sig_const, METH_VARARGS, signal_SIG_DFL_doc},
{"SIG_IGN", signal_sig_const, METH_VARARGS, signal_SIG_IGN_doc},
SIGNAL_SIG_DFL_METHODDEF
SIGNAL_SIG_IGN_METHODDEF
{NULL, NULL} /* sentinel */
};

Expand Down Expand Up @@ -1375,13 +1430,13 @@ PyInit__signal(void)
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);

x = DefaultHandler = PyDict_GetItemString(d, "SIG_DFL");
if (!x)
DefaultHandler = PyDict_GetItemString(d, "SIG_DFL");
if (!DefaultHandler)
goto finally;
Py_INCREF(DefaultHandler);

x = IgnoreHandler = PyDict_GetItemString(d, "SIG_IGN");
if (!x)
IgnoreHandler = PyDict_GetItemString(d, "SIG_IGN");
if (!IgnoreHandler)
goto finally;
Py_INCREF(IgnoreHandler);

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0