LCOV - code coverage report
Current view: top level - Modules/clinic - signalmodule.c.h (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 144 174 82.8 %
Date: 2022-07-07 18:19:46 Functions: 18 18 100.0 %

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

Generated by: LCOV version 1.14