blob: f3742262d8671ddeb3eb9c51f3ac6801cb78ccc6 [file] [log] [blame]
Tal Einatc7027b72015-05-16 14:14:49 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5#if defined(HAVE_ALARM)
6
7PyDoc_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
16static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030017signal_alarm_impl(PyObject *module, int seconds);
Tal Einatc7027b72015-05-16 14:14:49 +030018
19static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030020signal_alarm(PyObject *module, PyObject *arg)
Tal Einatc7027b72015-05-16 14:14:49 +030021{
22 PyObject *return_value = NULL;
23 int seconds;
24 long _return_value;
25
Serhiy Storchaka32d96a22018-12-25 13:23:47 +020026 if (PyFloat_Check(arg)) {
27 PyErr_SetString(PyExc_TypeError,
28 "integer argument expected, got float" );
29 goto exit;
30 }
31 seconds = _PyLong_AsInt(arg);
32 if (seconds == -1 && PyErr_Occurred()) {
Tal Einatc7027b72015-05-16 14:14:49 +030033 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030034 }
Tal Einatc7027b72015-05-16 14:14:49 +030035 _return_value = signal_alarm_impl(module, seconds);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030036 if ((_return_value == -1) && PyErr_Occurred()) {
Tal Einatc7027b72015-05-16 14:14:49 +030037 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030038 }
Tal Einatc7027b72015-05-16 14:14:49 +030039 return_value = PyLong_FromLong(_return_value);
40
41exit:
42 return return_value;
43}
44
45#endif /* defined(HAVE_ALARM) */
46
47#if defined(HAVE_PAUSE)
48
49PyDoc_STRVAR(signal_pause__doc__,
50"pause($module, /)\n"
51"--\n"
52"\n"
53"Wait until a signal arrives.");
54
55#define SIGNAL_PAUSE_METHODDEF \
56 {"pause", (PyCFunction)signal_pause, METH_NOARGS, signal_pause__doc__},
57
58static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030059signal_pause_impl(PyObject *module);
Tal Einatc7027b72015-05-16 14:14:49 +030060
61static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030062signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored))
Tal Einatc7027b72015-05-16 14:14:49 +030063{
64 return signal_pause_impl(module);
65}
66
67#endif /* defined(HAVE_PAUSE) */
68
Vladimir Matveevc24c6c22019-01-08 01:58:25 -080069PyDoc_STRVAR(signal_raise_signal__doc__,
70"raise_signal($module, signalnum, /)\n"
71"--\n"
72"\n"
73"Send a signal to the executing process.");
74
75#define SIGNAL_RAISE_SIGNAL_METHODDEF \
76 {"raise_signal", (PyCFunction)signal_raise_signal, METH_O, signal_raise_signal__doc__},
77
78static PyObject *
79signal_raise_signal_impl(PyObject *module, int signalnum);
80
81static PyObject *
82signal_raise_signal(PyObject *module, PyObject *arg)
83{
84 PyObject *return_value = NULL;
85 int signalnum;
86
87 if (PyFloat_Check(arg)) {
88 PyErr_SetString(PyExc_TypeError,
89 "integer argument expected, got float" );
90 goto exit;
91 }
92 signalnum = _PyLong_AsInt(arg);
93 if (signalnum == -1 && PyErr_Occurred()) {
94 goto exit;
95 }
96 return_value = signal_raise_signal_impl(module, signalnum);
97
98exit:
99 return return_value;
100}
101
Tal Einatc7027b72015-05-16 14:14:49 +0300102PyDoc_STRVAR(signal_signal__doc__,
103"signal($module, signalnum, handler, /)\n"
104"--\n"
105"\n"
106"Set the action for the given signal.\n"
107"\n"
108"The action can be SIG_DFL, SIG_IGN, or a callable Python object.\n"
109"The previous action is returned. See getsignal() for possible return values.\n"
110"\n"
111"*** IMPORTANT NOTICE ***\n"
112"A signal handler function is called with two arguments:\n"
113"the first is the signal number, the second is the interrupted stack frame.");
114
115#define SIGNAL_SIGNAL_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200116 {"signal", (PyCFunction)(void(*)(void))signal_signal, METH_FASTCALL, signal_signal__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300117
118static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300119signal_signal_impl(PyObject *module, int signalnum, PyObject *handler);
Tal Einatc7027b72015-05-16 14:14:49 +0300120
121static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200122signal_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300123{
124 PyObject *return_value = NULL;
125 int signalnum;
126 PyObject *handler;
127
Sylvain74453812017-06-10 06:51:48 +0200128 if (!_PyArg_ParseStack(args, nargs, "iO:signal",
129 &signalnum, &handler)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100130 goto exit;
131 }
Tal Einatc7027b72015-05-16 14:14:49 +0300132 return_value = signal_signal_impl(module, signalnum, handler);
133
134exit:
135 return return_value;
136}
137
138PyDoc_STRVAR(signal_getsignal__doc__,
139"getsignal($module, signalnum, /)\n"
140"--\n"
141"\n"
142"Return the current action for the given signal.\n"
143"\n"
144"The return value can be:\n"
145" SIG_IGN -- if the signal is being ignored\n"
146" SIG_DFL -- if the default action for the signal is in effect\n"
147" None -- if an unknown handler is in effect\n"
148" anything else -- the callable Python object used as a handler");
149
150#define SIGNAL_GETSIGNAL_METHODDEF \
151 {"getsignal", (PyCFunction)signal_getsignal, METH_O, signal_getsignal__doc__},
152
153static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300154signal_getsignal_impl(PyObject *module, int signalnum);
Tal Einatc7027b72015-05-16 14:14:49 +0300155
156static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300157signal_getsignal(PyObject *module, PyObject *arg)
Tal Einatc7027b72015-05-16 14:14:49 +0300158{
159 PyObject *return_value = NULL;
160 int signalnum;
161
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200162 if (PyFloat_Check(arg)) {
163 PyErr_SetString(PyExc_TypeError,
164 "integer argument expected, got float" );
165 goto exit;
166 }
167 signalnum = _PyLong_AsInt(arg);
168 if (signalnum == -1 && PyErr_Occurred()) {
Tal Einatc7027b72015-05-16 14:14:49 +0300169 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300170 }
Tal Einatc7027b72015-05-16 14:14:49 +0300171 return_value = signal_getsignal_impl(module, signalnum);
172
173exit:
174 return return_value;
175}
176
Antoine Pietri5d2a27d2018-03-12 14:42:34 +0100177PyDoc_STRVAR(signal_strsignal__doc__,
178"strsignal($module, signalnum, /)\n"
179"--\n"
180"\n"
181"Return the system description of the given signal.\n"
182"\n"
183"The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n"
184"Returns None if the signal is not recognized.");
185
186#define SIGNAL_STRSIGNAL_METHODDEF \
187 {"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__},
188
189static PyObject *
190signal_strsignal_impl(PyObject *module, int signalnum);
191
192static PyObject *
193signal_strsignal(PyObject *module, PyObject *arg)
194{
195 PyObject *return_value = NULL;
196 int signalnum;
197
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200198 if (PyFloat_Check(arg)) {
199 PyErr_SetString(PyExc_TypeError,
200 "integer argument expected, got float" );
201 goto exit;
202 }
203 signalnum = _PyLong_AsInt(arg);
204 if (signalnum == -1 && PyErr_Occurred()) {
Antoine Pietri5d2a27d2018-03-12 14:42:34 +0100205 goto exit;
206 }
207 return_value = signal_strsignal_impl(module, signalnum);
208
209exit:
210 return return_value;
211}
212
Tal Einatc7027b72015-05-16 14:14:49 +0300213#if defined(HAVE_SIGINTERRUPT)
214
215PyDoc_STRVAR(signal_siginterrupt__doc__,
216"siginterrupt($module, signalnum, flag, /)\n"
217"--\n"
218"\n"
219"Change system call restart behaviour.\n"
220"\n"
221"If flag is False, system calls will be restarted when interrupted by\n"
222"signal sig, else system calls will be interrupted.");
223
224#define SIGNAL_SIGINTERRUPT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200225 {"siginterrupt", (PyCFunction)(void(*)(void))signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300226
227static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300228signal_siginterrupt_impl(PyObject *module, int signalnum, int flag);
Tal Einatc7027b72015-05-16 14:14:49 +0300229
230static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200231signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300232{
233 PyObject *return_value = NULL;
234 int signalnum;
235 int flag;
236
Sylvain74453812017-06-10 06:51:48 +0200237 if (!_PyArg_ParseStack(args, nargs, "ii:siginterrupt",
238 &signalnum, &flag)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100239 goto exit;
240 }
Tal Einatc7027b72015-05-16 14:14:49 +0300241 return_value = signal_siginterrupt_impl(module, signalnum, flag);
242
243exit:
244 return return_value;
245}
246
247#endif /* defined(HAVE_SIGINTERRUPT) */
248
249#if defined(HAVE_SETITIMER)
250
251PyDoc_STRVAR(signal_setitimer__doc__,
252"setitimer($module, which, seconds, interval=0.0, /)\n"
253"--\n"
254"\n"
255"Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL or ITIMER_PROF).\n"
256"\n"
257"The timer will fire after value seconds and after that every interval seconds.\n"
258"The itimer can be cleared by setting seconds to zero.\n"
259"\n"
260"Returns old values as a tuple: (delay, interval).");
261
262#define SIGNAL_SETITIMER_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200263 {"setitimer", (PyCFunction)(void(*)(void))signal_setitimer, METH_FASTCALL, signal_setitimer__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300264
265static PyObject *
Victor Stinneref611c92017-10-13 13:49:43 -0700266signal_setitimer_impl(PyObject *module, int which, PyObject *seconds,
267 PyObject *interval);
Tal Einatc7027b72015-05-16 14:14:49 +0300268
269static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200270signal_setitimer(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300271{
272 PyObject *return_value = NULL;
273 int which;
Victor Stinneref611c92017-10-13 13:49:43 -0700274 PyObject *seconds;
275 PyObject *interval = NULL;
Tal Einatc7027b72015-05-16 14:14:49 +0300276
Victor Stinneref611c92017-10-13 13:49:43 -0700277 if (!_PyArg_ParseStack(args, nargs, "iO|O:setitimer",
Sylvain74453812017-06-10 06:51:48 +0200278 &which, &seconds, &interval)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100279 goto exit;
280 }
Tal Einatc7027b72015-05-16 14:14:49 +0300281 return_value = signal_setitimer_impl(module, which, seconds, interval);
282
283exit:
284 return return_value;
285}
286
287#endif /* defined(HAVE_SETITIMER) */
288
289#if defined(HAVE_GETITIMER)
290
291PyDoc_STRVAR(signal_getitimer__doc__,
292"getitimer($module, which, /)\n"
293"--\n"
294"\n"
295"Returns current value of given itimer.");
296
297#define SIGNAL_GETITIMER_METHODDEF \
298 {"getitimer", (PyCFunction)signal_getitimer, METH_O, signal_getitimer__doc__},
299
300static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300301signal_getitimer_impl(PyObject *module, int which);
Tal Einatc7027b72015-05-16 14:14:49 +0300302
303static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300304signal_getitimer(PyObject *module, PyObject *arg)
Tal Einatc7027b72015-05-16 14:14:49 +0300305{
306 PyObject *return_value = NULL;
307 int which;
308
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200309 if (PyFloat_Check(arg)) {
310 PyErr_SetString(PyExc_TypeError,
311 "integer argument expected, got float" );
312 goto exit;
313 }
314 which = _PyLong_AsInt(arg);
315 if (which == -1 && PyErr_Occurred()) {
Tal Einatc7027b72015-05-16 14:14:49 +0300316 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300317 }
Tal Einatc7027b72015-05-16 14:14:49 +0300318 return_value = signal_getitimer_impl(module, which);
319
320exit:
321 return return_value;
322}
323
324#endif /* defined(HAVE_GETITIMER) */
325
326#if defined(PYPTHREAD_SIGMASK)
327
328PyDoc_STRVAR(signal_pthread_sigmask__doc__,
329"pthread_sigmask($module, how, mask, /)\n"
330"--\n"
331"\n"
332"Fetch and/or change the signal mask of the calling thread.");
333
334#define SIGNAL_PTHREAD_SIGMASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200335 {"pthread_sigmask", (PyCFunction)(void(*)(void))signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300336
337static PyObject *
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300338signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask);
Tal Einatc7027b72015-05-16 14:14:49 +0300339
340static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200341signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300342{
343 PyObject *return_value = NULL;
344 int how;
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300345 sigset_t mask;
Tal Einatc7027b72015-05-16 14:14:49 +0300346
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300347 if (!_PyArg_ParseStack(args, nargs, "iO&:pthread_sigmask",
348 &how, _Py_Sigset_Converter, &mask)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100349 goto exit;
350 }
Tal Einatc7027b72015-05-16 14:14:49 +0300351 return_value = signal_pthread_sigmask_impl(module, how, mask);
352
353exit:
354 return return_value;
355}
356
357#endif /* defined(PYPTHREAD_SIGMASK) */
358
359#if defined(HAVE_SIGPENDING)
360
361PyDoc_STRVAR(signal_sigpending__doc__,
362"sigpending($module, /)\n"
363"--\n"
364"\n"
365"Examine pending signals.\n"
366"\n"
367"Returns a set of signal numbers that are pending for delivery to\n"
368"the calling thread.");
369
370#define SIGNAL_SIGPENDING_METHODDEF \
371 {"sigpending", (PyCFunction)signal_sigpending, METH_NOARGS, signal_sigpending__doc__},
372
373static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300374signal_sigpending_impl(PyObject *module);
Tal Einatc7027b72015-05-16 14:14:49 +0300375
376static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300377signal_sigpending(PyObject *module, PyObject *Py_UNUSED(ignored))
Tal Einatc7027b72015-05-16 14:14:49 +0300378{
379 return signal_sigpending_impl(module);
380}
381
382#endif /* defined(HAVE_SIGPENDING) */
383
384#if defined(HAVE_SIGWAIT)
385
386PyDoc_STRVAR(signal_sigwait__doc__,
387"sigwait($module, sigset, /)\n"
388"--\n"
389"\n"
390"Wait for a signal.\n"
391"\n"
392"Suspend execution of the calling thread until the delivery of one of the\n"
393"signals specified in the signal set sigset. The function accepts the signal\n"
394"and returns the signal number.");
395
396#define SIGNAL_SIGWAIT_METHODDEF \
397 {"sigwait", (PyCFunction)signal_sigwait, METH_O, signal_sigwait__doc__},
398
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300399static PyObject *
400signal_sigwait_impl(PyObject *module, sigset_t sigset);
401
402static PyObject *
403signal_sigwait(PyObject *module, PyObject *arg)
404{
405 PyObject *return_value = NULL;
406 sigset_t sigset;
407
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200408 if (!_Py_Sigset_Converter(arg, &sigset)) {
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300409 goto exit;
410 }
411 return_value = signal_sigwait_impl(module, sigset);
412
413exit:
414 return return_value;
415}
416
Tal Einatc7027b72015-05-16 14:14:49 +0300417#endif /* defined(HAVE_SIGWAIT) */
418
Antoine Pitrou9d3627e2018-05-04 13:00:50 +0200419#if (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS))
420
421PyDoc_STRVAR(signal_valid_signals__doc__,
422"valid_signals($module, /)\n"
423"--\n"
424"\n"
425"Return a set of valid signal numbers on this platform.\n"
426"\n"
427"The signal numbers returned by this function can be safely passed to\n"
428"functions like `pthread_sigmask`.");
429
430#define SIGNAL_VALID_SIGNALS_METHODDEF \
431 {"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__},
432
433static PyObject *
434signal_valid_signals_impl(PyObject *module);
435
436static PyObject *
437signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored))
438{
439 return signal_valid_signals_impl(module);
440}
441
442#endif /* (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)) */
443
Tal Einatc7027b72015-05-16 14:14:49 +0300444#if defined(HAVE_SIGWAITINFO)
445
446PyDoc_STRVAR(signal_sigwaitinfo__doc__,
447"sigwaitinfo($module, sigset, /)\n"
448"--\n"
449"\n"
450"Wait synchronously until one of the signals in *sigset* is delivered.\n"
451"\n"
452"Returns a struct_siginfo containing information about the signal.");
453
454#define SIGNAL_SIGWAITINFO_METHODDEF \
455 {"sigwaitinfo", (PyCFunction)signal_sigwaitinfo, METH_O, signal_sigwaitinfo__doc__},
456
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300457static PyObject *
458signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset);
459
460static PyObject *
461signal_sigwaitinfo(PyObject *module, PyObject *arg)
462{
463 PyObject *return_value = NULL;
464 sigset_t sigset;
465
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200466 if (!_Py_Sigset_Converter(arg, &sigset)) {
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300467 goto exit;
468 }
469 return_value = signal_sigwaitinfo_impl(module, sigset);
470
471exit:
472 return return_value;
473}
474
Tal Einatc7027b72015-05-16 14:14:49 +0300475#endif /* defined(HAVE_SIGWAITINFO) */
476
477#if defined(HAVE_SIGTIMEDWAIT)
478
479PyDoc_STRVAR(signal_sigtimedwait__doc__,
480"sigtimedwait($module, sigset, timeout, /)\n"
481"--\n"
482"\n"
483"Like sigwaitinfo(), but with a timeout.\n"
484"\n"
485"The timeout is specified in seconds, with floating point numbers allowed.");
486
487#define SIGNAL_SIGTIMEDWAIT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200488 {"sigtimedwait", (PyCFunction)(void(*)(void))signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300489
490static PyObject *
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300491signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
Serhiy Storchaka6b680cd2015-05-16 15:57:56 +0300492 PyObject *timeout_obj);
Tal Einatc7027b72015-05-16 14:14:49 +0300493
494static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200495signal_sigtimedwait(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300496{
497 PyObject *return_value = NULL;
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300498 sigset_t sigset;
Serhiy Storchaka6b680cd2015-05-16 15:57:56 +0300499 PyObject *timeout_obj;
Tal Einatc7027b72015-05-16 14:14:49 +0300500
Serhiy Storchakad54cfb12018-05-08 07:48:50 +0300501 if (!_PyArg_ParseStack(args, nargs, "O&O:sigtimedwait",
502 _Py_Sigset_Converter, &sigset, &timeout_obj)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100503 goto exit;
504 }
Serhiy Storchaka6b680cd2015-05-16 15:57:56 +0300505 return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj);
Tal Einatc7027b72015-05-16 14:14:49 +0300506
507exit:
508 return return_value;
509}
510
511#endif /* defined(HAVE_SIGTIMEDWAIT) */
512
Antoine Pitroua6a4dc82017-09-07 18:56:24 +0200513#if defined(HAVE_PTHREAD_KILL)
Tal Einatc7027b72015-05-16 14:14:49 +0300514
515PyDoc_STRVAR(signal_pthread_kill__doc__,
516"pthread_kill($module, thread_id, signalnum, /)\n"
517"--\n"
518"\n"
519"Send a signal to a thread.");
520
521#define SIGNAL_PTHREAD_KILL_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200522 {"pthread_kill", (PyCFunction)(void(*)(void))signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__},
Tal Einatc7027b72015-05-16 14:14:49 +0300523
524static PyObject *
Serhiy Storchakaaefa7eb2017-03-23 15:48:39 +0200525signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
526 int signalnum);
Tal Einatc7027b72015-05-16 14:14:49 +0300527
528static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200529signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Tal Einatc7027b72015-05-16 14:14:49 +0300530{
531 PyObject *return_value = NULL;
Serhiy Storchakaaefa7eb2017-03-23 15:48:39 +0200532 unsigned long thread_id;
Tal Einatc7027b72015-05-16 14:14:49 +0300533 int signalnum;
534
Sylvain74453812017-06-10 06:51:48 +0200535 if (!_PyArg_ParseStack(args, nargs, "ki:pthread_kill",
536 &thread_id, &signalnum)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100537 goto exit;
538 }
Tal Einatc7027b72015-05-16 14:14:49 +0300539 return_value = signal_pthread_kill_impl(module, thread_id, signalnum);
540
541exit:
542 return return_value;
543}
544
Antoine Pitroua6a4dc82017-09-07 18:56:24 +0200545#endif /* defined(HAVE_PTHREAD_KILL) */
Tal Einatc7027b72015-05-16 14:14:49 +0300546
547#ifndef SIGNAL_ALARM_METHODDEF
548 #define SIGNAL_ALARM_METHODDEF
549#endif /* !defined(SIGNAL_ALARM_METHODDEF) */
550
551#ifndef SIGNAL_PAUSE_METHODDEF
552 #define SIGNAL_PAUSE_METHODDEF
553#endif /* !defined(SIGNAL_PAUSE_METHODDEF) */
554
555#ifndef SIGNAL_SIGINTERRUPT_METHODDEF
556 #define SIGNAL_SIGINTERRUPT_METHODDEF
557#endif /* !defined(SIGNAL_SIGINTERRUPT_METHODDEF) */
558
559#ifndef SIGNAL_SETITIMER_METHODDEF
560 #define SIGNAL_SETITIMER_METHODDEF
561#endif /* !defined(SIGNAL_SETITIMER_METHODDEF) */
562
563#ifndef SIGNAL_GETITIMER_METHODDEF
564 #define SIGNAL_GETITIMER_METHODDEF
565#endif /* !defined(SIGNAL_GETITIMER_METHODDEF) */
566
567#ifndef SIGNAL_PTHREAD_SIGMASK_METHODDEF
568 #define SIGNAL_PTHREAD_SIGMASK_METHODDEF
569#endif /* !defined(SIGNAL_PTHREAD_SIGMASK_METHODDEF) */
570
571#ifndef SIGNAL_SIGPENDING_METHODDEF
572 #define SIGNAL_SIGPENDING_METHODDEF
573#endif /* !defined(SIGNAL_SIGPENDING_METHODDEF) */
574
575#ifndef SIGNAL_SIGWAIT_METHODDEF
576 #define SIGNAL_SIGWAIT_METHODDEF
577#endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */
578
Antoine Pitrou9d3627e2018-05-04 13:00:50 +0200579#ifndef SIGNAL_VALID_SIGNALS_METHODDEF
580 #define SIGNAL_VALID_SIGNALS_METHODDEF
581#endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */
582
Tal Einatc7027b72015-05-16 14:14:49 +0300583#ifndef SIGNAL_SIGWAITINFO_METHODDEF
584 #define SIGNAL_SIGWAITINFO_METHODDEF
585#endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */
586
587#ifndef SIGNAL_SIGTIMEDWAIT_METHODDEF
588 #define SIGNAL_SIGTIMEDWAIT_METHODDEF
589#endif /* !defined(SIGNAL_SIGTIMEDWAIT_METHODDEF) */
590
591#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
592 #define SIGNAL_PTHREAD_KILL_METHODDEF
593#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
Vladimir Matveevc24c6c22019-01-08 01:58:25 -0800594/*[clinic end generated code: output=365db4e807c26d4e input=a9049054013a1b77]*/