Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | #if defined(HAVE_ALARM) |
| 6 | |
| 7 | PyDoc_STRVAR(signal_alarm__doc__, |
| 8 | "alarm($module, seconds, /)\n" |
| 9 | "--\n" |
| 10 | "\n" |
| 11 | "Arrange for SIGALRM to arrive after the given number of seconds."); |
| 12 | |
| 13 | #define SIGNAL_ALARM_METHODDEF \ |
| 14 | {"alarm", (PyCFunction)signal_alarm, METH_O, signal_alarm__doc__}, |
| 15 | |
| 16 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 17 | signal_alarm_impl(PyObject *module, int seconds); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 18 | |
| 19 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 20 | signal_alarm(PyObject *module, PyObject *arg) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 21 | { |
| 22 | PyObject *return_value = NULL; |
| 23 | int seconds; |
| 24 | long _return_value; |
| 25 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 26 | if (!PyArg_Parse(arg, "i:alarm", &seconds)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 27 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 28 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 29 | _return_value = signal_alarm_impl(module, seconds); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 30 | if ((_return_value == -1) && PyErr_Occurred()) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 31 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 32 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 33 | return_value = PyLong_FromLong(_return_value); |
| 34 | |
| 35 | exit: |
| 36 | return return_value; |
| 37 | } |
| 38 | |
| 39 | #endif /* defined(HAVE_ALARM) */ |
| 40 | |
| 41 | #if defined(HAVE_PAUSE) |
| 42 | |
| 43 | PyDoc_STRVAR(signal_pause__doc__, |
| 44 | "pause($module, /)\n" |
| 45 | "--\n" |
| 46 | "\n" |
| 47 | "Wait until a signal arrives."); |
| 48 | |
| 49 | #define SIGNAL_PAUSE_METHODDEF \ |
| 50 | {"pause", (PyCFunction)signal_pause, METH_NOARGS, signal_pause__doc__}, |
| 51 | |
| 52 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 53 | signal_pause_impl(PyObject *module); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 54 | |
| 55 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 56 | signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 57 | { |
| 58 | return signal_pause_impl(module); |
| 59 | } |
| 60 | |
| 61 | #endif /* defined(HAVE_PAUSE) */ |
| 62 | |
| 63 | PyDoc_STRVAR(signal_signal__doc__, |
| 64 | "signal($module, signalnum, handler, /)\n" |
| 65 | "--\n" |
| 66 | "\n" |
| 67 | "Set the action for the given signal.\n" |
| 68 | "\n" |
| 69 | "The action can be SIG_DFL, SIG_IGN, or a callable Python object.\n" |
| 70 | "The previous action is returned. See getsignal() for possible return values.\n" |
| 71 | "\n" |
| 72 | "*** IMPORTANT NOTICE ***\n" |
| 73 | "A signal handler function is called with two arguments:\n" |
| 74 | "the first is the signal number, the second is the interrupted stack frame."); |
| 75 | |
| 76 | #define SIGNAL_SIGNAL_METHODDEF \ |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 77 | {"signal", (PyCFunction)signal_signal, METH_FASTCALL, signal_signal__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 78 | |
| 79 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 80 | signal_signal_impl(PyObject *module, int signalnum, PyObject *handler); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 81 | |
| 82 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 83 | signal_signal(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 84 | { |
| 85 | PyObject *return_value = NULL; |
| 86 | int signalnum; |
| 87 | PyObject *handler; |
| 88 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 89 | if (!_PyArg_ParseStack(args, nargs, "iO:signal", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 90 | &signalnum, &handler)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 91 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 92 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 93 | |
| 94 | if (!_PyArg_NoStackKeywords("signal", kwnames)) { |
| 95 | goto exit; |
| 96 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 97 | return_value = signal_signal_impl(module, signalnum, handler); |
| 98 | |
| 99 | exit: |
| 100 | return return_value; |
| 101 | } |
| 102 | |
| 103 | PyDoc_STRVAR(signal_getsignal__doc__, |
| 104 | "getsignal($module, signalnum, /)\n" |
| 105 | "--\n" |
| 106 | "\n" |
| 107 | "Return the current action for the given signal.\n" |
| 108 | "\n" |
| 109 | "The return value can be:\n" |
| 110 | " SIG_IGN -- if the signal is being ignored\n" |
| 111 | " SIG_DFL -- if the default action for the signal is in effect\n" |
| 112 | " None -- if an unknown handler is in effect\n" |
| 113 | " anything else -- the callable Python object used as a handler"); |
| 114 | |
| 115 | #define SIGNAL_GETSIGNAL_METHODDEF \ |
| 116 | {"getsignal", (PyCFunction)signal_getsignal, METH_O, signal_getsignal__doc__}, |
| 117 | |
| 118 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 119 | signal_getsignal_impl(PyObject *module, int signalnum); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 120 | |
| 121 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 122 | signal_getsignal(PyObject *module, PyObject *arg) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 123 | { |
| 124 | PyObject *return_value = NULL; |
| 125 | int signalnum; |
| 126 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 127 | if (!PyArg_Parse(arg, "i:getsignal", &signalnum)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 128 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 129 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 130 | return_value = signal_getsignal_impl(module, signalnum); |
| 131 | |
| 132 | exit: |
| 133 | return return_value; |
| 134 | } |
| 135 | |
| 136 | #if defined(HAVE_SIGINTERRUPT) |
| 137 | |
| 138 | PyDoc_STRVAR(signal_siginterrupt__doc__, |
| 139 | "siginterrupt($module, signalnum, flag, /)\n" |
| 140 | "--\n" |
| 141 | "\n" |
| 142 | "Change system call restart behaviour.\n" |
| 143 | "\n" |
| 144 | "If flag is False, system calls will be restarted when interrupted by\n" |
| 145 | "signal sig, else system calls will be interrupted."); |
| 146 | |
| 147 | #define SIGNAL_SIGINTERRUPT_METHODDEF \ |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 148 | {"siginterrupt", (PyCFunction)signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 149 | |
| 150 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 151 | signal_siginterrupt_impl(PyObject *module, int signalnum, int flag); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 152 | |
| 153 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 154 | signal_siginterrupt(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 155 | { |
| 156 | PyObject *return_value = NULL; |
| 157 | int signalnum; |
| 158 | int flag; |
| 159 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 160 | if (!_PyArg_ParseStack(args, nargs, "ii:siginterrupt", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 161 | &signalnum, &flag)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 162 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 163 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 164 | |
| 165 | if (!_PyArg_NoStackKeywords("siginterrupt", kwnames)) { |
| 166 | goto exit; |
| 167 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 168 | return_value = signal_siginterrupt_impl(module, signalnum, flag); |
| 169 | |
| 170 | exit: |
| 171 | return return_value; |
| 172 | } |
| 173 | |
| 174 | #endif /* defined(HAVE_SIGINTERRUPT) */ |
| 175 | |
| 176 | #if defined(HAVE_SETITIMER) |
| 177 | |
| 178 | PyDoc_STRVAR(signal_setitimer__doc__, |
| 179 | "setitimer($module, which, seconds, interval=0.0, /)\n" |
| 180 | "--\n" |
| 181 | "\n" |
| 182 | "Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL or ITIMER_PROF).\n" |
| 183 | "\n" |
| 184 | "The timer will fire after value seconds and after that every interval seconds.\n" |
| 185 | "The itimer can be cleared by setting seconds to zero.\n" |
| 186 | "\n" |
| 187 | "Returns old values as a tuple: (delay, interval)."); |
| 188 | |
| 189 | #define SIGNAL_SETITIMER_METHODDEF \ |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 190 | {"setitimer", (PyCFunction)signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 191 | |
| 192 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 193 | signal_setitimer_impl(PyObject *module, int which, double seconds, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 194 | double interval); |
| 195 | |
| 196 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 197 | signal_setitimer(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 198 | { |
| 199 | PyObject *return_value = NULL; |
| 200 | int which; |
| 201 | double seconds; |
| 202 | double interval = 0.0; |
| 203 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 204 | if (!_PyArg_ParseStack(args, nargs, "id|d:setitimer", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 205 | &which, &seconds, &interval)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 206 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 207 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 208 | |
| 209 | if (!_PyArg_NoStackKeywords("setitimer", kwnames)) { |
| 210 | goto exit; |
| 211 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 212 | return_value = signal_setitimer_impl(module, which, seconds, interval); |
| 213 | |
| 214 | exit: |
| 215 | return return_value; |
| 216 | } |
| 217 | |
| 218 | #endif /* defined(HAVE_SETITIMER) */ |
| 219 | |
| 220 | #if defined(HAVE_GETITIMER) |
| 221 | |
| 222 | PyDoc_STRVAR(signal_getitimer__doc__, |
| 223 | "getitimer($module, which, /)\n" |
| 224 | "--\n" |
| 225 | "\n" |
| 226 | "Returns current value of given itimer."); |
| 227 | |
| 228 | #define SIGNAL_GETITIMER_METHODDEF \ |
| 229 | {"getitimer", (PyCFunction)signal_getitimer, METH_O, signal_getitimer__doc__}, |
| 230 | |
| 231 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 232 | signal_getitimer_impl(PyObject *module, int which); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 233 | |
| 234 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 235 | signal_getitimer(PyObject *module, PyObject *arg) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 236 | { |
| 237 | PyObject *return_value = NULL; |
| 238 | int which; |
| 239 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 240 | if (!PyArg_Parse(arg, "i:getitimer", &which)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 241 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 242 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 243 | return_value = signal_getitimer_impl(module, which); |
| 244 | |
| 245 | exit: |
| 246 | return return_value; |
| 247 | } |
| 248 | |
| 249 | #endif /* defined(HAVE_GETITIMER) */ |
| 250 | |
| 251 | #if defined(PYPTHREAD_SIGMASK) |
| 252 | |
| 253 | PyDoc_STRVAR(signal_pthread_sigmask__doc__, |
| 254 | "pthread_sigmask($module, how, mask, /)\n" |
| 255 | "--\n" |
| 256 | "\n" |
| 257 | "Fetch and/or change the signal mask of the calling thread."); |
| 258 | |
| 259 | #define SIGNAL_PTHREAD_SIGMASK_METHODDEF \ |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 260 | {"pthread_sigmask", (PyCFunction)signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 261 | |
| 262 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 263 | signal_pthread_sigmask_impl(PyObject *module, int how, PyObject *mask); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 264 | |
| 265 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 266 | signal_pthread_sigmask(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 267 | { |
| 268 | PyObject *return_value = NULL; |
| 269 | int how; |
| 270 | PyObject *mask; |
| 271 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 272 | if (!_PyArg_ParseStack(args, nargs, "iO:pthread_sigmask", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 273 | &how, &mask)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 274 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 275 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 276 | |
| 277 | if (!_PyArg_NoStackKeywords("pthread_sigmask", kwnames)) { |
| 278 | goto exit; |
| 279 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 280 | return_value = signal_pthread_sigmask_impl(module, how, mask); |
| 281 | |
| 282 | exit: |
| 283 | return return_value; |
| 284 | } |
| 285 | |
| 286 | #endif /* defined(PYPTHREAD_SIGMASK) */ |
| 287 | |
| 288 | #if defined(HAVE_SIGPENDING) |
| 289 | |
| 290 | PyDoc_STRVAR(signal_sigpending__doc__, |
| 291 | "sigpending($module, /)\n" |
| 292 | "--\n" |
| 293 | "\n" |
| 294 | "Examine pending signals.\n" |
| 295 | "\n" |
| 296 | "Returns a set of signal numbers that are pending for delivery to\n" |
| 297 | "the calling thread."); |
| 298 | |
| 299 | #define SIGNAL_SIGPENDING_METHODDEF \ |
| 300 | {"sigpending", (PyCFunction)signal_sigpending, METH_NOARGS, signal_sigpending__doc__}, |
| 301 | |
| 302 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 303 | signal_sigpending_impl(PyObject *module); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 304 | |
| 305 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 306 | signal_sigpending(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 307 | { |
| 308 | return signal_sigpending_impl(module); |
| 309 | } |
| 310 | |
| 311 | #endif /* defined(HAVE_SIGPENDING) */ |
| 312 | |
| 313 | #if defined(HAVE_SIGWAIT) |
| 314 | |
| 315 | PyDoc_STRVAR(signal_sigwait__doc__, |
| 316 | "sigwait($module, sigset, /)\n" |
| 317 | "--\n" |
| 318 | "\n" |
| 319 | "Wait for a signal.\n" |
| 320 | "\n" |
| 321 | "Suspend execution of the calling thread until the delivery of one of the\n" |
| 322 | "signals specified in the signal set sigset. The function accepts the signal\n" |
| 323 | "and returns the signal number."); |
| 324 | |
| 325 | #define SIGNAL_SIGWAIT_METHODDEF \ |
| 326 | {"sigwait", (PyCFunction)signal_sigwait, METH_O, signal_sigwait__doc__}, |
| 327 | |
| 328 | #endif /* defined(HAVE_SIGWAIT) */ |
| 329 | |
| 330 | #if defined(HAVE_SIGWAITINFO) |
| 331 | |
| 332 | PyDoc_STRVAR(signal_sigwaitinfo__doc__, |
| 333 | "sigwaitinfo($module, sigset, /)\n" |
| 334 | "--\n" |
| 335 | "\n" |
| 336 | "Wait synchronously until one of the signals in *sigset* is delivered.\n" |
| 337 | "\n" |
| 338 | "Returns a struct_siginfo containing information about the signal."); |
| 339 | |
| 340 | #define SIGNAL_SIGWAITINFO_METHODDEF \ |
| 341 | {"sigwaitinfo", (PyCFunction)signal_sigwaitinfo, METH_O, signal_sigwaitinfo__doc__}, |
| 342 | |
| 343 | #endif /* defined(HAVE_SIGWAITINFO) */ |
| 344 | |
| 345 | #if defined(HAVE_SIGTIMEDWAIT) |
| 346 | |
| 347 | PyDoc_STRVAR(signal_sigtimedwait__doc__, |
| 348 | "sigtimedwait($module, sigset, timeout, /)\n" |
| 349 | "--\n" |
| 350 | "\n" |
| 351 | "Like sigwaitinfo(), but with a timeout.\n" |
| 352 | "\n" |
| 353 | "The timeout is specified in seconds, with floating point numbers allowed."); |
| 354 | |
| 355 | #define SIGNAL_SIGTIMEDWAIT_METHODDEF \ |
Victor Stinner | 0c4a828 | 2017-01-17 02:21:47 +0100 | [diff] [blame] | 356 | {"sigtimedwait", (PyCFunction)signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 357 | |
| 358 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 359 | signal_sigtimedwait_impl(PyObject *module, PyObject *sigset, |
Serhiy Storchaka | 6b680cd | 2015-05-16 15:57:56 +0300 | [diff] [blame] | 360 | PyObject *timeout_obj); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 361 | |
| 362 | static PyObject * |
Victor Stinner | 0c4a828 | 2017-01-17 02:21:47 +0100 | [diff] [blame] | 363 | signal_sigtimedwait(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 364 | { |
| 365 | PyObject *return_value = NULL; |
| 366 | PyObject *sigset; |
Serhiy Storchaka | 6b680cd | 2015-05-16 15:57:56 +0300 | [diff] [blame] | 367 | PyObject *timeout_obj; |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 368 | |
Victor Stinner | 0c4a828 | 2017-01-17 02:21:47 +0100 | [diff] [blame] | 369 | if (!_PyArg_UnpackStack(args, nargs, "sigtimedwait", |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 370 | 2, 2, |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 371 | &sigset, &timeout_obj)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 372 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 373 | } |
Victor Stinner | 0c4a828 | 2017-01-17 02:21:47 +0100 | [diff] [blame] | 374 | |
| 375 | if (!_PyArg_NoStackKeywords("sigtimedwait", kwnames)) { |
| 376 | goto exit; |
| 377 | } |
Serhiy Storchaka | 6b680cd | 2015-05-16 15:57:56 +0300 | [diff] [blame] | 378 | return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 379 | |
| 380 | exit: |
| 381 | return return_value; |
| 382 | } |
| 383 | |
| 384 | #endif /* defined(HAVE_SIGTIMEDWAIT) */ |
| 385 | |
| 386 | #if (defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD)) |
| 387 | |
| 388 | PyDoc_STRVAR(signal_pthread_kill__doc__, |
| 389 | "pthread_kill($module, thread_id, signalnum, /)\n" |
| 390 | "--\n" |
| 391 | "\n" |
| 392 | "Send a signal to a thread."); |
| 393 | |
| 394 | #define SIGNAL_PTHREAD_KILL_METHODDEF \ |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 395 | {"pthread_kill", (PyCFunction)signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 396 | |
| 397 | static PyObject * |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame^] | 398 | signal_pthread_kill_impl(PyObject *module, unsigned long thread_id, |
| 399 | int signalnum); |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 400 | |
| 401 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 402 | signal_pthread_kill(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 403 | { |
| 404 | PyObject *return_value = NULL; |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame^] | 405 | unsigned long thread_id; |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 406 | int signalnum; |
| 407 | |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame^] | 408 | if (!_PyArg_ParseStack(args, nargs, "ki:pthread_kill", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 409 | &thread_id, &signalnum)) { |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 410 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 411 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 412 | |
| 413 | if (!_PyArg_NoStackKeywords("pthread_kill", kwnames)) { |
| 414 | goto exit; |
| 415 | } |
Tal Einat | c7027b7 | 2015-05-16 14:14:49 +0300 | [diff] [blame] | 416 | return_value = signal_pthread_kill_impl(module, thread_id, signalnum); |
| 417 | |
| 418 | exit: |
| 419 | return return_value; |
| 420 | } |
| 421 | |
| 422 | #endif /* (defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD)) */ |
| 423 | |
| 424 | #ifndef SIGNAL_ALARM_METHODDEF |
| 425 | #define SIGNAL_ALARM_METHODDEF |
| 426 | #endif /* !defined(SIGNAL_ALARM_METHODDEF) */ |
| 427 | |
| 428 | #ifndef SIGNAL_PAUSE_METHODDEF |
| 429 | #define SIGNAL_PAUSE_METHODDEF |
| 430 | #endif /* !defined(SIGNAL_PAUSE_METHODDEF) */ |
| 431 | |
| 432 | #ifndef SIGNAL_SIGINTERRUPT_METHODDEF |
| 433 | #define SIGNAL_SIGINTERRUPT_METHODDEF |
| 434 | #endif /* !defined(SIGNAL_SIGINTERRUPT_METHODDEF) */ |
| 435 | |
| 436 | #ifndef SIGNAL_SETITIMER_METHODDEF |
| 437 | #define SIGNAL_SETITIMER_METHODDEF |
| 438 | #endif /* !defined(SIGNAL_SETITIMER_METHODDEF) */ |
| 439 | |
| 440 | #ifndef SIGNAL_GETITIMER_METHODDEF |
| 441 | #define SIGNAL_GETITIMER_METHODDEF |
| 442 | #endif /* !defined(SIGNAL_GETITIMER_METHODDEF) */ |
| 443 | |
| 444 | #ifndef SIGNAL_PTHREAD_SIGMASK_METHODDEF |
| 445 | #define SIGNAL_PTHREAD_SIGMASK_METHODDEF |
| 446 | #endif /* !defined(SIGNAL_PTHREAD_SIGMASK_METHODDEF) */ |
| 447 | |
| 448 | #ifndef SIGNAL_SIGPENDING_METHODDEF |
| 449 | #define SIGNAL_SIGPENDING_METHODDEF |
| 450 | #endif /* !defined(SIGNAL_SIGPENDING_METHODDEF) */ |
| 451 | |
| 452 | #ifndef SIGNAL_SIGWAIT_METHODDEF |
| 453 | #define SIGNAL_SIGWAIT_METHODDEF |
| 454 | #endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */ |
| 455 | |
| 456 | #ifndef SIGNAL_SIGWAITINFO_METHODDEF |
| 457 | #define SIGNAL_SIGWAITINFO_METHODDEF |
| 458 | #endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */ |
| 459 | |
| 460 | #ifndef SIGNAL_SIGTIMEDWAIT_METHODDEF |
| 461 | #define SIGNAL_SIGTIMEDWAIT_METHODDEF |
| 462 | #endif /* !defined(SIGNAL_SIGTIMEDWAIT_METHODDEF) */ |
| 463 | |
| 464 | #ifndef SIGNAL_PTHREAD_KILL_METHODDEF |
| 465 | #define SIGNAL_PTHREAD_KILL_METHODDEF |
| 466 | #endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */ |
Serhiy Storchaka | aefa7eb | 2017-03-23 15:48:39 +0200 | [diff] [blame^] | 467 | /*[clinic end generated code: output=c1a3f374b2c77e5d input=a9049054013a1b77]*/ |