LCOV - code coverage report
Current view: top level - Modules/clinic - signalmodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 174 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 18 0.0 %
Branches: 0 128 0.0 %

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

Generated by: LCOV version 1.14