summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-02-23 15:07:35 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-02-23 15:07:35 (GMT)
commit7e251e83d5b488904212f91bace1322d12475803 (patch)
tree29f24e91e6a5261772816d5b500937b59e9a819d /Modules/signalmodule.c
parent57826cf9f8c1d75da8d7d0e27f564adb441329ad (diff)
downloadcpython-7e251e83d5b488904212f91bace1322d12475803.zip
cpython-7e251e83d5b488904212f91bace1322d12475803.tar.gz
cpython-7e251e83d5b488904212f91bace1322d12475803.tar.bz2
Issue 1089358. Adds the siginterrupt() function, that is just a
wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 9dec24f..8acec21 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -272,6 +272,36 @@ SIG_DFL -- if the default action for the signal is in effect\n\
None -- if an unknown handler is in effect\n\
anything else -- the callable Python object used as a handler");
+#ifdef HAVE_SIGINTERRUPT
+PyDoc_STRVAR(siginterrupt_doc,
+"siginterrupt(sig, flag) -> None\n\
+change system call restart behaviour: if flag is False, system calls\n\
+will be restarted when interrupted by signal sig, else system calls\n\
+will be interrupted.");
+
+static PyObject *
+signal_siginterrupt(PyObject *self, PyObject *args)
+{
+ int sig_num;
+ int flag;
+
+ if (!PyArg_ParseTuple(args, "ii:siginterrupt", &sig_num, &flag))
+ return NULL;
+ if (sig_num < 1 || sig_num >= NSIG) {
+ PyErr_SetString(PyExc_ValueError,
+ "signal number out of range");
+ return NULL;
+ }
+ if (siginterrupt(sig_num, flag)<0) {
+ PyErr_SetFromErrno(PyExc_RuntimeError);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#endif
static PyObject *
signal_set_wakeup_fd(PyObject *self, PyObject *args)
@@ -325,6 +355,9 @@ static PyMethodDef signal_methods[] = {
{"signal", signal_signal, METH_VARARGS, signal_doc},
{"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc},
{"set_wakeup_fd", signal_set_wakeup_fd, METH_VARARGS, set_wakeup_fd_doc},
+#ifdef HAVE_SIGINTERRUPT
+ {"siginterrupt", signal_siginterrupt, METH_VARARGS, siginterrupt_doc},
+#endif
#ifdef HAVE_PAUSE
{"pause", (PyCFunction)signal_pause,
METH_NOARGS,pause_doc},