/src/Python-3.8.3/Modules/clinic/signalmodule.c.h
Line | Count | Source (jump to first uncovered line) |
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 |
17 | | signal_alarm_impl(PyObject *module, int seconds); |
18 | | |
19 | | static PyObject * |
20 | | signal_alarm(PyObject *module, PyObject *arg) |
21 | 0 | { |
22 | 0 | PyObject *return_value = NULL; |
23 | 0 | int seconds; |
24 | 0 | long _return_value; |
25 | |
|
26 | 0 | if (PyFloat_Check(arg)) { |
27 | 0 | PyErr_SetString(PyExc_TypeError, |
28 | 0 | "integer argument expected, got float" ); |
29 | 0 | goto exit; |
30 | 0 | } |
31 | 0 | seconds = _PyLong_AsInt(arg); |
32 | 0 | if (seconds == -1 && PyErr_Occurred()) { |
33 | 0 | goto exit; |
34 | 0 | } |
35 | 0 | _return_value = signal_alarm_impl(module, seconds); |
36 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
37 | 0 | goto exit; |
38 | 0 | } |
39 | 0 | return_value = PyLong_FromLong(_return_value); |
40 | |
|
41 | 0 | exit: |
42 | 0 | return return_value; |
43 | 0 | } |
44 | | |
45 | | #endif /* defined(HAVE_ALARM) */ |
46 | | |
47 | | #if defined(HAVE_PAUSE) |
48 | | |
49 | | PyDoc_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 | | |
58 | | static PyObject * |
59 | | signal_pause_impl(PyObject *module); |
60 | | |
61 | | static PyObject * |
62 | | signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored)) |
63 | 0 | { |
64 | 0 | return signal_pause_impl(module); |
65 | 0 | } |
66 | | |
67 | | #endif /* defined(HAVE_PAUSE) */ |
68 | | |
69 | | PyDoc_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 | | |
78 | | static PyObject * |
79 | | signal_raise_signal_impl(PyObject *module, int signalnum); |
80 | | |
81 | | static PyObject * |
82 | | signal_raise_signal(PyObject *module, PyObject *arg) |
83 | 0 | { |
84 | 0 | PyObject *return_value = NULL; |
85 | 0 | int signalnum; |
86 | |
|
87 | 0 | if (PyFloat_Check(arg)) { |
88 | 0 | PyErr_SetString(PyExc_TypeError, |
89 | 0 | "integer argument expected, got float" ); |
90 | 0 | goto exit; |
91 | 0 | } |
92 | 0 | signalnum = _PyLong_AsInt(arg); |
93 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
94 | 0 | goto exit; |
95 | 0 | } |
96 | 0 | return_value = signal_raise_signal_impl(module, signalnum); |
97 | |
|
98 | 0 | exit: |
99 | 0 | return return_value; |
100 | 0 | } |
101 | | |
102 | | PyDoc_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 \ |
116 | | {"signal", (PyCFunction)(void(*)(void))signal_signal, METH_FASTCALL, signal_signal__doc__}, |
117 | | |
118 | | static PyObject * |
119 | | signal_signal_impl(PyObject *module, int signalnum, PyObject *handler); |
120 | | |
121 | | static PyObject * |
122 | | signal_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
123 | 0 | { |
124 | 0 | PyObject *return_value = NULL; |
125 | 0 | int signalnum; |
126 | 0 | PyObject *handler; |
127 | |
|
128 | 0 | if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) { |
129 | 0 | goto exit; |
130 | 0 | } |
131 | 0 | if (PyFloat_Check(args[0])) { |
132 | 0 | PyErr_SetString(PyExc_TypeError, |
133 | 0 | "integer argument expected, got float" ); |
134 | 0 | goto exit; |
135 | 0 | } |
136 | 0 | signalnum = _PyLong_AsInt(args[0]); |
137 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
138 | 0 | goto exit; |
139 | 0 | } |
140 | 0 | handler = args[1]; |
141 | 0 | return_value = signal_signal_impl(module, signalnum, handler); |
142 | |
|
143 | 0 | exit: |
144 | 0 | return return_value; |
145 | 0 | } |
146 | | |
147 | | PyDoc_STRVAR(signal_getsignal__doc__, |
148 | | "getsignal($module, signalnum, /)\n" |
149 | | "--\n" |
150 | | "\n" |
151 | | "Return the current action for the given signal.\n" |
152 | | "\n" |
153 | | "The return value can be:\n" |
154 | | " SIG_IGN -- if the signal is being ignored\n" |
155 | | " SIG_DFL -- if the default action for the signal is in effect\n" |
156 | | " None -- if an unknown handler is in effect\n" |
157 | | " anything else -- the callable Python object used as a handler"); |
158 | | |
159 | | #define SIGNAL_GETSIGNAL_METHODDEF \ |
160 | | {"getsignal", (PyCFunction)signal_getsignal, METH_O, signal_getsignal__doc__}, |
161 | | |
162 | | static PyObject * |
163 | | signal_getsignal_impl(PyObject *module, int signalnum); |
164 | | |
165 | | static PyObject * |
166 | | signal_getsignal(PyObject *module, PyObject *arg) |
167 | 0 | { |
168 | 0 | PyObject *return_value = NULL; |
169 | 0 | int signalnum; |
170 | |
|
171 | 0 | if (PyFloat_Check(arg)) { |
172 | 0 | PyErr_SetString(PyExc_TypeError, |
173 | 0 | "integer argument expected, got float" ); |
174 | 0 | goto exit; |
175 | 0 | } |
176 | 0 | signalnum = _PyLong_AsInt(arg); |
177 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
178 | 0 | goto exit; |
179 | 0 | } |
180 | 0 | return_value = signal_getsignal_impl(module, signalnum); |
181 | |
|
182 | 0 | exit: |
183 | 0 | return return_value; |
184 | 0 | } |
185 | | |
186 | | PyDoc_STRVAR(signal_strsignal__doc__, |
187 | | "strsignal($module, signalnum, /)\n" |
188 | | "--\n" |
189 | | "\n" |
190 | | "Return the system description of the given signal.\n" |
191 | | "\n" |
192 | | "The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n" |
193 | | "Returns None if the signal is not recognized."); |
194 | | |
195 | | #define SIGNAL_STRSIGNAL_METHODDEF \ |
196 | | {"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__}, |
197 | | |
198 | | static PyObject * |
199 | | signal_strsignal_impl(PyObject *module, int signalnum); |
200 | | |
201 | | static PyObject * |
202 | | signal_strsignal(PyObject *module, PyObject *arg) |
203 | 0 | { |
204 | 0 | PyObject *return_value = NULL; |
205 | 0 | int signalnum; |
206 | |
|
207 | 0 | if (PyFloat_Check(arg)) { |
208 | 0 | PyErr_SetString(PyExc_TypeError, |
209 | 0 | "integer argument expected, got float" ); |
210 | 0 | goto exit; |
211 | 0 | } |
212 | 0 | signalnum = _PyLong_AsInt(arg); |
213 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
214 | 0 | goto exit; |
215 | 0 | } |
216 | 0 | return_value = signal_strsignal_impl(module, signalnum); |
217 | |
|
218 | 0 | exit: |
219 | 0 | return return_value; |
220 | 0 | } |
221 | | |
222 | | #if defined(HAVE_SIGINTERRUPT) |
223 | | |
224 | | PyDoc_STRVAR(signal_siginterrupt__doc__, |
225 | | "siginterrupt($module, signalnum, flag, /)\n" |
226 | | "--\n" |
227 | | "\n" |
228 | | "Change system call restart behaviour.\n" |
229 | | "\n" |
230 | | "If flag is False, system calls will be restarted when interrupted by\n" |
231 | | "signal sig, else system calls will be interrupted."); |
232 | | |
233 | | #define SIGNAL_SIGINTERRUPT_METHODDEF \ |
234 | | {"siginterrupt", (PyCFunction)(void(*)(void))signal_siginterrupt, METH_FASTCALL, signal_siginterrupt__doc__}, |
235 | | |
236 | | static PyObject * |
237 | | signal_siginterrupt_impl(PyObject *module, int signalnum, int flag); |
238 | | |
239 | | static PyObject * |
240 | | signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
241 | 0 | { |
242 | 0 | PyObject *return_value = NULL; |
243 | 0 | int signalnum; |
244 | 0 | int flag; |
245 | |
|
246 | 0 | if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) { |
247 | 0 | goto exit; |
248 | 0 | } |
249 | 0 | if (PyFloat_Check(args[0])) { |
250 | 0 | PyErr_SetString(PyExc_TypeError, |
251 | 0 | "integer argument expected, got float" ); |
252 | 0 | goto exit; |
253 | 0 | } |
254 | 0 | signalnum = _PyLong_AsInt(args[0]); |
255 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
256 | 0 | goto exit; |
257 | 0 | } |
258 | 0 | if (PyFloat_Check(args[1])) { |
259 | 0 | PyErr_SetString(PyExc_TypeError, |
260 | 0 | "integer argument expected, got float" ); |
261 | 0 | goto exit; |
262 | 0 | } |
263 | 0 | flag = _PyLong_AsInt(args[1]); |
264 | 0 | if (flag == -1 && PyErr_Occurred()) { |
265 | 0 | goto exit; |
266 | 0 | } |
267 | 0 | return_value = signal_siginterrupt_impl(module, signalnum, flag); |
268 | |
|
269 | 0 | exit: |
270 | 0 | return return_value; |
271 | 0 | } |
272 | | |
273 | | #endif /* defined(HAVE_SIGINTERRUPT) */ |
274 | | |
275 | | #if defined(HAVE_SETITIMER) |
276 | | |
277 | | PyDoc_STRVAR(signal_setitimer__doc__, |
278 | | "setitimer($module, which, seconds, interval=0.0, /)\n" |
279 | | "--\n" |
280 | | "\n" |
281 | | "Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL or ITIMER_PROF).\n" |
282 | | "\n" |
283 | | "The timer will fire after value seconds and after that every interval seconds.\n" |
284 | | "The itimer can be cleared by setting seconds to zero.\n" |
285 | | "\n" |
286 | | "Returns old values as a tuple: (delay, interval)."); |
287 | | |
288 | | #define SIGNAL_SETITIMER_METHODDEF \ |
289 | | {"setitimer", (PyCFunction)(void(*)(void))signal_setitimer, METH_FASTCALL, signal_setitimer__doc__}, |
290 | | |
291 | | static PyObject * |
292 | | signal_setitimer_impl(PyObject *module, int which, PyObject *seconds, |
293 | | PyObject *interval); |
294 | | |
295 | | static PyObject * |
296 | | signal_setitimer(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
297 | 0 | { |
298 | 0 | PyObject *return_value = NULL; |
299 | 0 | int which; |
300 | 0 | PyObject *seconds; |
301 | 0 | PyObject *interval = NULL; |
302 | |
|
303 | 0 | if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) { |
304 | 0 | goto exit; |
305 | 0 | } |
306 | 0 | if (PyFloat_Check(args[0])) { |
307 | 0 | PyErr_SetString(PyExc_TypeError, |
308 | 0 | "integer argument expected, got float" ); |
309 | 0 | goto exit; |
310 | 0 | } |
311 | 0 | which = _PyLong_AsInt(args[0]); |
312 | 0 | if (which == -1 && PyErr_Occurred()) { |
313 | 0 | goto exit; |
314 | 0 | } |
315 | 0 | seconds = args[1]; |
316 | 0 | if (nargs < 3) { |
317 | 0 | goto skip_optional; |
318 | 0 | } |
319 | 0 | interval = args[2]; |
320 | 0 | skip_optional: |
321 | 0 | return_value = signal_setitimer_impl(module, which, seconds, interval); |
322 | |
|
323 | 0 | exit: |
324 | 0 | return return_value; |
325 | 0 | } |
326 | | |
327 | | #endif /* defined(HAVE_SETITIMER) */ |
328 | | |
329 | | #if defined(HAVE_GETITIMER) |
330 | | |
331 | | PyDoc_STRVAR(signal_getitimer__doc__, |
332 | | "getitimer($module, which, /)\n" |
333 | | "--\n" |
334 | | "\n" |
335 | | "Returns current value of given itimer."); |
336 | | |
337 | | #define SIGNAL_GETITIMER_METHODDEF \ |
338 | | {"getitimer", (PyCFunction)signal_getitimer, METH_O, signal_getitimer__doc__}, |
339 | | |
340 | | static PyObject * |
341 | | signal_getitimer_impl(PyObject *module, int which); |
342 | | |
343 | | static PyObject * |
344 | | signal_getitimer(PyObject *module, PyObject *arg) |
345 | 0 | { |
346 | 0 | PyObject *return_value = NULL; |
347 | 0 | int which; |
348 | |
|
349 | 0 | if (PyFloat_Check(arg)) { |
350 | 0 | PyErr_SetString(PyExc_TypeError, |
351 | 0 | "integer argument expected, got float" ); |
352 | 0 | goto exit; |
353 | 0 | } |
354 | 0 | which = _PyLong_AsInt(arg); |
355 | 0 | if (which == -1 && PyErr_Occurred()) { |
356 | 0 | goto exit; |
357 | 0 | } |
358 | 0 | return_value = signal_getitimer_impl(module, which); |
359 | |
|
360 | 0 | exit: |
361 | 0 | return return_value; |
362 | 0 | } |
363 | | |
364 | | #endif /* defined(HAVE_GETITIMER) */ |
365 | | |
366 | | #if defined(PYPTHREAD_SIGMASK) |
367 | | |
368 | | PyDoc_STRVAR(signal_pthread_sigmask__doc__, |
369 | | "pthread_sigmask($module, how, mask, /)\n" |
370 | | "--\n" |
371 | | "\n" |
372 | | "Fetch and/or change the signal mask of the calling thread."); |
373 | | |
374 | | #define SIGNAL_PTHREAD_SIGMASK_METHODDEF \ |
375 | | {"pthread_sigmask", (PyCFunction)(void(*)(void))signal_pthread_sigmask, METH_FASTCALL, signal_pthread_sigmask__doc__}, |
376 | | |
377 | | static PyObject * |
378 | | signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask); |
379 | | |
380 | | static PyObject * |
381 | | signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
382 | 0 | { |
383 | 0 | PyObject *return_value = NULL; |
384 | 0 | int how; |
385 | 0 | sigset_t mask; |
386 | |
|
387 | 0 | if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) { |
388 | 0 | goto exit; |
389 | 0 | } |
390 | 0 | if (PyFloat_Check(args[0])) { |
391 | 0 | PyErr_SetString(PyExc_TypeError, |
392 | 0 | "integer argument expected, got float" ); |
393 | 0 | goto exit; |
394 | 0 | } |
395 | 0 | how = _PyLong_AsInt(args[0]); |
396 | 0 | if (how == -1 && PyErr_Occurred()) { |
397 | 0 | goto exit; |
398 | 0 | } |
399 | 0 | if (!_Py_Sigset_Converter(args[1], &mask)) { |
400 | 0 | goto exit; |
401 | 0 | } |
402 | 0 | return_value = signal_pthread_sigmask_impl(module, how, mask); |
403 | |
|
404 | 0 | exit: |
405 | 0 | return return_value; |
406 | 0 | } |
407 | | |
408 | | #endif /* defined(PYPTHREAD_SIGMASK) */ |
409 | | |
410 | | #if defined(HAVE_SIGPENDING) |
411 | | |
412 | | PyDoc_STRVAR(signal_sigpending__doc__, |
413 | | "sigpending($module, /)\n" |
414 | | "--\n" |
415 | | "\n" |
416 | | "Examine pending signals.\n" |
417 | | "\n" |
418 | | "Returns a set of signal numbers that are pending for delivery to\n" |
419 | | "the calling thread."); |
420 | | |
421 | | #define SIGNAL_SIGPENDING_METHODDEF \ |
422 | | {"sigpending", (PyCFunction)signal_sigpending, METH_NOARGS, signal_sigpending__doc__}, |
423 | | |
424 | | static PyObject * |
425 | | signal_sigpending_impl(PyObject *module); |
426 | | |
427 | | static PyObject * |
428 | | signal_sigpending(PyObject *module, PyObject *Py_UNUSED(ignored)) |
429 | 0 | { |
430 | 0 | return signal_sigpending_impl(module); |
431 | 0 | } |
432 | | |
433 | | #endif /* defined(HAVE_SIGPENDING) */ |
434 | | |
435 | | #if defined(HAVE_SIGWAIT) |
436 | | |
437 | | PyDoc_STRVAR(signal_sigwait__doc__, |
438 | | "sigwait($module, sigset, /)\n" |
439 | | "--\n" |
440 | | "\n" |
441 | | "Wait for a signal.\n" |
442 | | "\n" |
443 | | "Suspend execution of the calling thread until the delivery of one of the\n" |
444 | | "signals specified in the signal set sigset. The function accepts the signal\n" |
445 | | "and returns the signal number."); |
446 | | |
447 | | #define SIGNAL_SIGWAIT_METHODDEF \ |
448 | | {"sigwait", (PyCFunction)signal_sigwait, METH_O, signal_sigwait__doc__}, |
449 | | |
450 | | static PyObject * |
451 | | signal_sigwait_impl(PyObject *module, sigset_t sigset); |
452 | | |
453 | | static PyObject * |
454 | | signal_sigwait(PyObject *module, PyObject *arg) |
455 | 0 | { |
456 | 0 | PyObject *return_value = NULL; |
457 | 0 | sigset_t sigset; |
458 | |
|
459 | 0 | if (!_Py_Sigset_Converter(arg, &sigset)) { |
460 | 0 | goto exit; |
461 | 0 | } |
462 | 0 | return_value = signal_sigwait_impl(module, sigset); |
463 | |
|
464 | 0 | exit: |
465 | 0 | return return_value; |
466 | 0 | } |
467 | | |
468 | | #endif /* defined(HAVE_SIGWAIT) */ |
469 | | |
470 | | #if (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)) |
471 | | |
472 | | PyDoc_STRVAR(signal_valid_signals__doc__, |
473 | | "valid_signals($module, /)\n" |
474 | | "--\n" |
475 | | "\n" |
476 | | "Return a set of valid signal numbers on this platform.\n" |
477 | | "\n" |
478 | | "The signal numbers returned by this function can be safely passed to\n" |
479 | | "functions like `pthread_sigmask`."); |
480 | | |
481 | | #define SIGNAL_VALID_SIGNALS_METHODDEF \ |
482 | | {"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__}, |
483 | | |
484 | | static PyObject * |
485 | | signal_valid_signals_impl(PyObject *module); |
486 | | |
487 | | static PyObject * |
488 | | signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored)) |
489 | 0 | { |
490 | 0 | return signal_valid_signals_impl(module); |
491 | 0 | } |
492 | | |
493 | | #endif /* (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)) */ |
494 | | |
495 | | #if defined(HAVE_SIGWAITINFO) |
496 | | |
497 | | PyDoc_STRVAR(signal_sigwaitinfo__doc__, |
498 | | "sigwaitinfo($module, sigset, /)\n" |
499 | | "--\n" |
500 | | "\n" |
501 | | "Wait synchronously until one of the signals in *sigset* is delivered.\n" |
502 | | "\n" |
503 | | "Returns a struct_siginfo containing information about the signal."); |
504 | | |
505 | | #define SIGNAL_SIGWAITINFO_METHODDEF \ |
506 | | {"sigwaitinfo", (PyCFunction)signal_sigwaitinfo, METH_O, signal_sigwaitinfo__doc__}, |
507 | | |
508 | | static PyObject * |
509 | | signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset); |
510 | | |
511 | | static PyObject * |
512 | | signal_sigwaitinfo(PyObject *module, PyObject *arg) |
513 | 0 | { |
514 | 0 | PyObject *return_value = NULL; |
515 | 0 | sigset_t sigset; |
516 | |
|
517 | 0 | if (!_Py_Sigset_Converter(arg, &sigset)) { |
518 | 0 | goto exit; |
519 | 0 | } |
520 | 0 | return_value = signal_sigwaitinfo_impl(module, sigset); |
521 | |
|
522 | 0 | exit: |
523 | 0 | return return_value; |
524 | 0 | } |
525 | | |
526 | | #endif /* defined(HAVE_SIGWAITINFO) */ |
527 | | |
528 | | #if defined(HAVE_SIGTIMEDWAIT) |
529 | | |
530 | | PyDoc_STRVAR(signal_sigtimedwait__doc__, |
531 | | "sigtimedwait($module, sigset, timeout, /)\n" |
532 | | "--\n" |
533 | | "\n" |
534 | | "Like sigwaitinfo(), but with a timeout.\n" |
535 | | "\n" |
536 | | "The timeout is specified in seconds, with floating point numbers allowed."); |
537 | | |
538 | | #define SIGNAL_SIGTIMEDWAIT_METHODDEF \ |
539 | | {"sigtimedwait", (PyCFunction)(void(*)(void))signal_sigtimedwait, METH_FASTCALL, signal_sigtimedwait__doc__}, |
540 | | |
541 | | static PyObject * |
542 | | signal_sigtimedwait_impl(PyObject *module, sigset_t sigset, |
543 | | PyObject *timeout_obj); |
544 | | |
545 | | static PyObject * |
546 | | signal_sigtimedwait(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
547 | 0 | { |
548 | 0 | PyObject *return_value = NULL; |
549 | 0 | sigset_t sigset; |
550 | 0 | PyObject *timeout_obj; |
551 | |
|
552 | 0 | if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) { |
553 | 0 | goto exit; |
554 | 0 | } |
555 | 0 | if (!_Py_Sigset_Converter(args[0], &sigset)) { |
556 | 0 | goto exit; |
557 | 0 | } |
558 | 0 | timeout_obj = args[1]; |
559 | 0 | return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj); |
560 | |
|
561 | 0 | exit: |
562 | 0 | return return_value; |
563 | 0 | } |
564 | | |
565 | | #endif /* defined(HAVE_SIGTIMEDWAIT) */ |
566 | | |
567 | | #if defined(HAVE_PTHREAD_KILL) |
568 | | |
569 | | PyDoc_STRVAR(signal_pthread_kill__doc__, |
570 | | "pthread_kill($module, thread_id, signalnum, /)\n" |
571 | | "--\n" |
572 | | "\n" |
573 | | "Send a signal to a thread."); |
574 | | |
575 | | #define SIGNAL_PTHREAD_KILL_METHODDEF \ |
576 | | {"pthread_kill", (PyCFunction)(void(*)(void))signal_pthread_kill, METH_FASTCALL, signal_pthread_kill__doc__}, |
577 | | |
578 | | static PyObject * |
579 | | signal_pthread_kill_impl(PyObject *module, unsigned long thread_id, |
580 | | int signalnum); |
581 | | |
582 | | static PyObject * |
583 | | signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
584 | 0 | { |
585 | 0 | PyObject *return_value = NULL; |
586 | 0 | unsigned long thread_id; |
587 | 0 | int signalnum; |
588 | |
|
589 | 0 | if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) { |
590 | 0 | goto exit; |
591 | 0 | } |
592 | 0 | if (!PyLong_Check(args[0])) { |
593 | 0 | _PyArg_BadArgument("pthread_kill", "argument 1", "int", args[0]); |
594 | 0 | goto exit; |
595 | 0 | } |
596 | 0 | thread_id = PyLong_AsUnsignedLongMask(args[0]); |
597 | 0 | if (PyFloat_Check(args[1])) { |
598 | 0 | PyErr_SetString(PyExc_TypeError, |
599 | 0 | "integer argument expected, got float" ); |
600 | 0 | goto exit; |
601 | 0 | } |
602 | 0 | signalnum = _PyLong_AsInt(args[1]); |
603 | 0 | if (signalnum == -1 && PyErr_Occurred()) { |
604 | 0 | goto exit; |
605 | 0 | } |
606 | 0 | return_value = signal_pthread_kill_impl(module, thread_id, signalnum); |
607 | |
|
608 | 0 | exit: |
609 | 0 | return return_value; |
610 | 0 | } |
611 | | |
612 | | #endif /* defined(HAVE_PTHREAD_KILL) */ |
613 | | |
614 | | #ifndef SIGNAL_ALARM_METHODDEF |
615 | | #define SIGNAL_ALARM_METHODDEF |
616 | | #endif /* !defined(SIGNAL_ALARM_METHODDEF) */ |
617 | | |
618 | | #ifndef SIGNAL_PAUSE_METHODDEF |
619 | | #define SIGNAL_PAUSE_METHODDEF |
620 | | #endif /* !defined(SIGNAL_PAUSE_METHODDEF) */ |
621 | | |
622 | | #ifndef SIGNAL_SIGINTERRUPT_METHODDEF |
623 | | #define SIGNAL_SIGINTERRUPT_METHODDEF |
624 | | #endif /* !defined(SIGNAL_SIGINTERRUPT_METHODDEF) */ |
625 | | |
626 | | #ifndef SIGNAL_SETITIMER_METHODDEF |
627 | | #define SIGNAL_SETITIMER_METHODDEF |
628 | | #endif /* !defined(SIGNAL_SETITIMER_METHODDEF) */ |
629 | | |
630 | | #ifndef SIGNAL_GETITIMER_METHODDEF |
631 | | #define SIGNAL_GETITIMER_METHODDEF |
632 | | #endif /* !defined(SIGNAL_GETITIMER_METHODDEF) */ |
633 | | |
634 | | #ifndef SIGNAL_PTHREAD_SIGMASK_METHODDEF |
635 | | #define SIGNAL_PTHREAD_SIGMASK_METHODDEF |
636 | | #endif /* !defined(SIGNAL_PTHREAD_SIGMASK_METHODDEF) */ |
637 | | |
638 | | #ifndef SIGNAL_SIGPENDING_METHODDEF |
639 | | #define SIGNAL_SIGPENDING_METHODDEF |
640 | | #endif /* !defined(SIGNAL_SIGPENDING_METHODDEF) */ |
641 | | |
642 | | #ifndef SIGNAL_SIGWAIT_METHODDEF |
643 | | #define SIGNAL_SIGWAIT_METHODDEF |
644 | | #endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */ |
645 | | |
646 | | #ifndef SIGNAL_VALID_SIGNALS_METHODDEF |
647 | | #define SIGNAL_VALID_SIGNALS_METHODDEF |
648 | | #endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */ |
649 | | |
650 | | #ifndef SIGNAL_SIGWAITINFO_METHODDEF |
651 | | #define SIGNAL_SIGWAITINFO_METHODDEF |
652 | | #endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */ |
653 | | |
654 | | #ifndef SIGNAL_SIGTIMEDWAIT_METHODDEF |
655 | | #define SIGNAL_SIGTIMEDWAIT_METHODDEF |
656 | | #endif /* !defined(SIGNAL_SIGTIMEDWAIT_METHODDEF) */ |
657 | | |
658 | | #ifndef SIGNAL_PTHREAD_KILL_METHODDEF |
659 | | #define SIGNAL_PTHREAD_KILL_METHODDEF |
660 | | #endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */ |
661 | | /*[clinic end generated code: output=3320b8f73c20ba60 input=a9049054013a1b77]*/ |