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