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