1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
|
/*[clinic input]
preserve
[clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
PyDoc_STRVAR(signal_default_int_handler__doc__,
"default_int_handler($module, signalnum, frame, /)\n"
"--\n"
"\n"
"The default handler for SIGINT installed by Python.\n"
"\n"
"It raises KeyboardInterrupt.");
#define SIGNAL_DEFAULT_INT_HANDLER_METHODDEF \
{"default_int_handler", _PyCFunction_CAST(signal_default_int_handler), METH_FASTCALL, signal_default_int_handler__doc__},
static PyObject *
signal_default_int_handler_impl(PyObject *module, int signalnum,
PyObject *frame);
static PyObject *
signal_default_int_handler(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int signalnum;
PyObject *frame;
if (!_PyArg_CheckPositional("default_int_handler", nargs, 2, 2)) {
goto exit;
}
signalnum = PyLong_AsInt(args[0]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
frame = args[1];
return_value = signal_default_int_handler_impl(module, signalnum, frame);
exit:
return return_value;
}
#if defined(HAVE_ALARM)
PyDoc_STRVAR(signal_alarm__doc__,
"alarm($module, seconds, /)\n"
"--\n"
"\n"
"Arrange for SIGALRM to arrive after the given number of seconds.");
#define SIGNAL_ALARM_METHODDEF \
{"alarm", (PyCFunction)signal_alarm, METH_O, signal_alarm__doc__},
static long
signal_alarm_impl(PyObject *module, int seconds);
static PyObject *
signal_alarm(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int seconds;
long _return_value;
seconds = PyLong_AsInt(arg);
if (seconds == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = signal_alarm_impl(module, seconds);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong(_return_value);
exit:
return return_value;
}
#endif /* defined(HAVE_ALARM) */
#if defined(HAVE_PAUSE)
PyDoc_STRVAR(signal_pause__doc__,
"pause($module, /)\n"
"--\n"
"\n"
"Wait until a signal arrives.");
#define SIGNAL_PAUSE_METHODDEF \
{"pause", (PyCFunction)signal_pause, METH_NOARGS, signal_pause__doc__},
static PyObject *
signal_pause_impl(PyObject *module);
static PyObject *
signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return signal_pause_impl(module);
}
#endif /* defined(HAVE_PAUSE) */
PyDoc_STRVAR(signal_raise_signal__doc__,
"raise_signal($module, signalnum, /)\n"
"--\n"
"\n"
"Send a signal to the executing process.");
#define SIGNAL_RAISE_SIGNAL_METHODDEF \
{"raise_signal", (PyCFunction)signal_raise_signal, METH_O, signal_raise_signal__doc__},
static PyObject *
signal_raise_signal_impl(PyObject *module, int signalnum);
static PyObject *
signal_raise_signal(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int signalnum;
signalnum = PyLong_AsInt(arg);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_raise_signal_impl(module, signalnum);
exit:
return return_value;
}
PyDoc_STRVAR(signal_signal__doc__,
"signal($module, signalnum, handler, /)\n"
"--\n"
"\n"
"Set the action for the given signal.\n"
"\n"
"The action can be SIG_DFL, SIG_IGN, or a callable Python object.\n"
"The previous action is returned. See getsignal() for possible return values.\n"
"\n"
"*** IMPORTANT NOTICE ***\n"
"A signal handler function is called with two arguments:\n"
"the first is the signal number, the second is the interrupted stack frame.");
#define SIGNAL_SIGNAL_METHODDEF \
{"signal", _PyCFunction_CAST(signal_signal), METH_FASTCALL, signal_signal__doc__},
static PyObject *
signal_signal_impl(PyObject *module, int signalnum, PyObject *handler);
static PyObject *
signal_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int signalnum;
PyObject *handler;
if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) {
goto exit;
}
signalnum = PyLong_AsInt(args[0]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
handler = args[1];
return_value = signal_signal_impl(module, signalnum, handler);
exit:
return return_value;
}
PyDoc_STRVAR(signal_getsignal__doc__,
"getsignal($module, signalnum, /)\n"
"--\n"
"\n"
"Return the current action for the given signal.\n"
"\n"
"The return value can be:\n"
" SIG_IGN -- if the signal is being ignored\n"
" SIG_DFL -- if the default action for the signal is in effect\n"
" None -- if an unknown handler is in effect\n"
" anything else -- the callable Python object used as a handler");
#define SIGNAL_GETSIGNAL_METHODDEF \
{"getsignal", (PyCFunction)signal_getsignal, METH_O, signal_getsignal__doc__},
static PyObject *
signal_getsignal_impl(PyObject *module, int signalnum);
static PyObject *
signal_getsignal(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int signalnum;
signalnum = PyLong_AsInt(arg);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_getsignal_impl(module, signalnum);
exit:
return return_value;
}
PyDoc_STRVAR(signal_strsignal__doc__,
"strsignal($module, signalnum, /)\n"
"--\n"
"\n"
"Return the system description of the given signal.\n"
"\n"
"Returns the description of signal *signalnum*, such as \"Interrupt\"\n"
"for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no\n"
"description. Raises :exc:`ValueError` if *signalnum* is invalid.");
#define SIGNAL_STRSIGNAL_METHODDEF \
{"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__},
static PyObject *
signal_strsignal_impl(PyObject *module, int signalnum);
static PyObject *
signal_strsignal(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int signalnum;
signalnum = PyLong_AsInt(arg);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_strsignal_impl(module, signalnum);
exit:
return return_value;
}
#if defined(HAVE_SIGINTERRUPT)
PyDoc_STRVAR(signal_siginterrupt__doc__,
"siginterrupt($module, signalnum, flag, /)\n"
"--\n"
"\n"
"Change system call restart behaviour.\n"
"\n"
"If flag is False, system calls will be restarted when interrupted by\n"
"signal sig, else system calls will be interrupted.");
#define SIGNAL_SIGINTERRUPT_METHODDEF \
{"siginterrupt", _PyCFunction_CAST(signal_siginterrupt), METH_FASTCALL, signal_siginterrupt__doc__},
static PyObject *
signal_siginterrupt_impl(PyObject *module, int signalnum, int flag);
static PyObject *
signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int signalnum;
int flag;
if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) {
goto exit;
}
signalnum = PyLong_AsInt(args[0]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
flag = PyLong_AsInt(args[1]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_siginterrupt_impl(module, signalnum, flag);
exit:
return return_value;
}
#endif /* defined(HAVE_SIGINTERRUPT) */
PyDoc_STRVAR(signal_set_wakeup_fd__doc__,
"set_wakeup_fd($module, fd, /, *, warn_on_full_buffer=True)\n"
"--\n"
"\n"
"Sets the fd to be written to (with the signal number) when a signal comes in.\n"
"\n"
"A library can use this to wakeup select or poll.\n"
"The previous fd or -1 is returned.\n"
"\n"
"The fd must be non-blocking.");
#define SIGNAL_SET_WAKEUP_FD_METHODDEF \
{"set_wakeup_fd", _PyCFunction_CAST(signal_set_wakeup_fd), METH_FASTCALL|METH_KEYWORDS, signal_set_wakeup_fd__doc__},
static PyObject *
signal_set_wakeup_fd_impl(PyObject *module, PyObject *fdobj,
int warn_on_full_buffer);
static PyObject *
signal_set_wakeup_fd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 1
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_item = { &_Py_ID(warn_on_full_buffer), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
#else // !Py_BUILD_CORE
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
static const char * const _keywords[] = {"", "warn_on_full_buffer", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "set_wakeup_fd",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
PyObject *argsbuf[2];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *fdobj;
int warn_on_full_buffer = 1;
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
if (!args) {
goto exit;
}
fdobj = args[0];
if (!noptargs) {
goto skip_optional_kwonly;
}
warn_on_full_buffer = PyObject_IsTrue(args[1]);
if (warn_on_full_buffer < 0) {
goto exit;
}
skip_optional_kwonly:
return_value = signal_set_wakeup_fd_impl(module, fdobj, warn_on_full_buffer);
exit:
return return_value;
}
#if defined(HAVE_SETITIMER)
PyDoc_STRVAR(signal_setitimer__doc__,
"setitimer($module, which, seconds, interval=0.0, /)\n"
"--\n"
"\n"
"Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL or ITIMER_PROF).\n"
"\n"
"The timer will fire after value seconds and after that every interval seconds.\n"
"The itimer can be cleared by setting seconds to zero.\n"
"\n"
"Returns old values as a tuple: (delay, interval).");
#define SIGNAL_SETITIMER_METHODDEF \
{"setitimer", _PyCFunction_CAST(signal_setitimer), METH_FASTCALL, signal_setitimer__doc__},
static PyObject *
signal_setitimer_impl(PyObject *module, int which, PyObject *seconds,
PyObject *interval);
static PyObject *
signal_setitimer(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int which;
PyObject *seconds;
PyObject *interval = NULL;
if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) {
goto exit;
}
which = PyLong_AsInt(args[0]);
if (which == -1 && PyErr_Occurred()) {
goto exit;
}
seconds = args[1];
if (nargs < 3) {
goto skip_optional;
}
interval = args[2];
skip_optional:
return_value = signal_setitimer_impl(module, which, seconds, interval);
exit:
return return_value;
}
#endif /* defined(HAVE_SETITIMER) */
#if defined(HAVE_GETITIMER)
PyDoc_STRVAR(signal_getitimer__doc__,
"getitimer($module, which, /)\n"
"--\n"
"\n"
"Returns current value of given itimer.");
#define SIGNAL_GETITIMER_METHODDEF \
{"getitimer", (PyCFunction)signal_getitimer, METH_O, signal_getitimer__doc__},
static PyObject *
signal_getitimer_impl(PyObject *module, int which);
static PyObject *
signal_getitimer(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int which;
which = PyLong_AsInt(arg);
if (which == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_getitimer_impl(module, which);
exit:
return return_value;
}
#endif /* defined(HAVE_GETITIMER) */
#if defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK)
PyDoc_STRVAR(signal_pthread_sigmask__doc__,
"pthread_sigmask($module, how, mask, /)\n"
"--\n"
"\n"
"Fetch and/or change the signal mask of the calling thread.");
#define SIGNAL_PTHREAD_SIGMASK_METHODDEF \
{"pthread_sigmask", _PyCFunction_CAST(signal_pthread_sigmask), METH_FASTCALL, signal_pthread_sigmask__doc__},
static PyObject *
signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask);
static PyObject *
signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int how;
sigset_t mask;
if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) {
goto exit;
}
how = PyLong_AsInt(args[0]);
if (how == -1 && PyErr_Occurred()) {
goto exit;
}
if (!_Py_Sigset_Converter(args[1], &mask)) {
goto exit;
}
return_value = signal_pthread_sigmask_impl(module, how, mask);
exit:
return return_value;
}
#endif /* defined(HAVE_SIGSET_T) && defined(PYPTHREAD_SIGMASK) */
#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING)
PyDoc_STRVAR(signal_sigpending__doc__,
"sigpending($module, /)\n"
"--\n"
"\n"
"Examine pending signals.\n"
"\n"
"Returns a set of signal numbers that are pending for delivery to\n"
"the calling thread.");
#define SIGNAL_SIGPENDING_METHODDEF \
{"sigpending", (PyCFunction)signal_sigpending, METH_NOARGS, signal_sigpending__doc__},
static PyObject *
signal_sigpending_impl(PyObject *module);
static PyObject *
signal_sigpending(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return signal_sigpending_impl(module);
}
#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGPENDING) */
#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT)
PyDoc_STRVAR(signal_sigwait__doc__,
"sigwait($module, sigset, /)\n"
"--\n"
"\n"
"Wait for a signal.\n"
"\n"
"Suspend execution of the calling thread until the delivery of one of the\n"
"signals specified in the signal set sigset. The function accepts the signal\n"
"and returns the signal number.");
#define SIGNAL_SIGWAIT_METHODDEF \
{"sigwait", (PyCFunction)signal_sigwait, METH_O, signal_sigwait__doc__},
static PyObject *
signal_sigwait_impl(PyObject *module, sigset_t sigset);
static PyObject *
signal_sigwait(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
sigset_t sigset;
if (!_Py_Sigset_Converter(arg, &sigset)) {
goto exit;
}
return_value = signal_sigwait_impl(module, sigset);
exit:
return return_value;
}
#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAIT) */
#if ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS))
PyDoc_STRVAR(signal_valid_signals__doc__,
"valid_signals($module, /)\n"
"--\n"
"\n"
"Return a set of valid signal numbers on this platform.\n"
"\n"
"The signal numbers returned by this function can be safely passed to\n"
"functions like `pthread_sigmask`.");
#define SIGNAL_VALID_SIGNALS_METHODDEF \
{"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__},
static PyObject *
signal_valid_signals_impl(PyObject *module);
static PyObject *
signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return signal_valid_signals_impl(module);
}
#endif /* ((defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)) */
#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO)
PyDoc_STRVAR(signal_sigwaitinfo__doc__,
"sigwaitinfo($module, sigset, /)\n"
"--\n"
"\n"
"Wait synchronously until one of the signals in *sigset* is delivered.\n"
"\n"
"Returns a struct_siginfo containing information about the signal.");
#define SIGNAL_SIGWAITINFO_METHODDEF \
{"sigwaitinfo", (PyCFunction)signal_sigwaitinfo, METH_O, signal_sigwaitinfo__doc__},
static PyObject *
signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset);
static PyObject *
signal_sigwaitinfo(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
sigset_t sigset;
if (!_Py_Sigset_Converter(arg, &sigset)) {
goto exit;
}
return_value = signal_sigwaitinfo_impl(module, sigset);
exit:
return return_value;
}
#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGWAITINFO) */
#if defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT)
PyDoc_STRVAR(signal_sigtimedwait__doc__,
"sigtimedwait($module, sigset, timeout, /)\n"
"--\n"
"\n"
"Like sigwaitinfo(), but with a timeout.\n"
"\n"
"The timeout is specified in seconds, with floating-point numbers allowed.");
#define SIGNAL_SIGTIMEDWAIT_METHODDEF \
{"sigtimedwait", _PyCFunction_CAST(signal_sigtimedwait), METH_FASTCALL, signal_sigtimedwait__doc__},
static PyObject *
signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
PyObject *timeout_obj);
static PyObject *
signal_sigtimedwait(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
sigset_t sigset;
PyObject *timeout_obj;
if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) {
goto exit;
}
if (!_Py_Sigset_Converter(args[0], &sigset)) {
goto exit;
}
timeout_obj = args[1];
return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj);
exit:
return return_value;
}
#endif /* defined(HAVE_SIGSET_T) && defined(HAVE_SIGTIMEDWAIT) */
#if defined(HAVE_PTHREAD_KILL)
PyDoc_STRVAR(signal_pthread_kill__doc__,
"pthread_kill($module, thread_id, signalnum, /)\n"
"--\n"
"\n"
"Send a signal to a thread.");
#define SIGNAL_PTHREAD_KILL_METHODDEF \
{"pthread_kill", _PyCFunction_CAST(signal_pthread_kill), METH_FASTCALL, signal_pthread_kill__doc__},
static PyObject *
signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
int signalnum);
static PyObject *
signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
unsigned long thread_id;
int signalnum;
if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) {
goto exit;
}
if (!PyLong_Check(args[0])) {
_PyArg_BadArgument("pthread_kill", "argument 1", "int", args[0]);
goto exit;
}
thread_id = PyLong_AsUnsignedLongMask(args[0]);
signalnum = PyLong_AsInt(args[1]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_pthread_kill_impl(module, thread_id, signalnum);
exit:
return return_value;
}
#endif /* defined(HAVE_PTHREAD_KILL) */
#if (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))
PyDoc_STRVAR(signal_pidfd_send_signal__doc__,
"pidfd_send_signal($module, pidfd, signalnum, siginfo=None, flags=0, /)\n"
"--\n"
"\n"
"Send a signal to a process referred to by a pid file descriptor.");
#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF \
{"pidfd_send_signal", _PyCFunction_CAST(signal_pidfd_send_signal), METH_FASTCALL, signal_pidfd_send_signal__doc__},
static PyObject *
signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum,
PyObject *siginfo, int flags);
static PyObject *
signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int pidfd;
int signalnum;
PyObject *siginfo = Py_None;
int flags = 0;
if (!_PyArg_CheckPositional("pidfd_send_signal", nargs, 2, 4)) {
goto exit;
}
pidfd = PyLong_AsInt(args[0]);
if (pidfd == -1 && PyErr_Occurred()) {
goto exit;
}
signalnum = PyLong_AsInt(args[1]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
siginfo = args[2];
if (nargs < 4) {
goto skip_optional;
}
flags = PyLong_AsInt(args[3]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = signal_pidfd_send_signal_impl(module, pidfd, signalnum, siginfo, flags);
exit:
return return_value;
}
#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */
#ifndef SIGNAL_ALARM_METHODDEF
#define SIGNAL_ALARM_METHODDEF
#endif /* !defined(SIGNAL_ALARM_METHODDEF) */
#ifndef SIGNAL_PAUSE_METHODDEF
#define SIGNAL_PAUSE_METHODDEF
#endif /* !defined(SIGNAL_PAUSE_METHODDEF) */
#ifndef SIGNAL_SIGINTERRUPT_METHODDEF
#define SIGNAL_SIGINTERRUPT_METHODDEF
#endif /* !defined(SIGNAL_SIGINTERRUPT_METHODDEF) */
#ifndef SIGNAL_SETITIMER_METHODDEF
#define SIGNAL_SETITIMER_METHODDEF
#endif /* !defined(SIGNAL_SETITIMER_METHODDEF) */
#ifndef SIGNAL_GETITIMER_METHODDEF
#define SIGNAL_GETITIMER_METHODDEF
#endif /* !defined(SIGNAL_GETITIMER_METHODDEF) */
#ifndef SIGNAL_PTHREAD_SIGMASK_METHODDEF
#define SIGNAL_PTHREAD_SIGMASK_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_SIGMASK_METHODDEF) */
#ifndef SIGNAL_SIGPENDING_METHODDEF
#define SIGNAL_SIGPENDING_METHODDEF
#endif /* !defined(SIGNAL_SIGPENDING_METHODDEF) */
#ifndef SIGNAL_SIGWAIT_METHODDEF
#define SIGNAL_SIGWAIT_METHODDEF
#endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */
#ifndef SIGNAL_VALID_SIGNALS_METHODDEF
#define SIGNAL_VALID_SIGNALS_METHODDEF
#endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */
#ifndef SIGNAL_SIGWAITINFO_METHODDEF
#define SIGNAL_SIGWAITINFO_METHODDEF
#endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */
#ifndef SIGNAL_SIGTIMEDWAIT_METHODDEF
#define SIGNAL_SIGTIMEDWAIT_METHODDEF
#endif /* !defined(SIGNAL_SIGTIMEDWAIT_METHODDEF) */
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */
/*[clinic end generated code: output=c57b4b98fad6f4b8 input=a9049054013a1b77]*/
|