Lines Matching +full:handle +full:- +full:sigint
2 /* Signal module -- many thanks to Lance Ellinghaus */
51 # define SIG_ERR ((PyOS_sighandler_t)(-1))
78 - only the main thread can set a signal handler
79 - only the main thread runs the signal handler
80 - signals can be delivered to any thread
81 - any thread can get a signal handler
85 signals as a means of inter-thread communication, since not all
90 generated by the keyboard (e.g. SIGINT) are delivered to all
102 /* func is atomic to ensure that PyErr_SetInterrupt is async-signal-safe
109 #define INVALID_FD ((SOCKET_T)-1)
117 #define INVALID_FD (-1)
135 HANDLE sigint_event;
183 tv->tv_sec = 0; in timeval_from_double()
184 tv->tv_usec = 0; in timeval_from_double()
190 return -1; in timeval_from_double()
198 return tv->tv_sec + (double)(tv->tv_usec / 1000000.0); in double_from_timeval()
210 if(!(v = PyFloat_FromDouble(double_from_timeval(&iv->it_value)))) { in itimer_retval()
217 if(!(v = PyFloat_FromDouble(double_from_timeval(&iv->it_interval)))) { in itimer_retval()
234 The default handler for SIGINT installed by Python.
303 - main thread blocks on select([wakeup.fd], ...) in trip_signal()
304 - signal arrives in trip_signal()
305 - trip_signal writes to the wakeup fd in trip_signal()
306 - the main thread wakes up in trip_signal()
307 - the main thread checks the signal flags, sees that they're unset in trip_signal()
308 - the main thread empties the wakeup fd in trip_signal()
309 - the main thread goes back to sleep in trip_signal()
310 - trip_signal sets the flags to request the Python-level signal handler in trip_signal()
312 - the main thread doesn't notice, because it's asleep in trip_signal()
314 See bpo-30038 for more details. in trip_signal()
335 /* _PyEval_AddPendingCall() isn't signal-safe, but we in trip_signal()
354 /* _PyEval_AddPendingCall() isn't signal-safe, but we in trip_signal()
375 reset until explicit re-instated. in signal_handler()
391 if (sig_num == SIGINT) { in signal_handler()
393 SetEvent(state->sigint_event); in signal_handler()
402 signal.alarm -> long
507 case SIGINT: break; in signal_signal_impl()
517 if (!_Py_ThreadCanHandleSignals(tstate->interp)) { in signal_signal_impl()
528 if (handler == modstate->ignore_handler) { in signal_signal_impl()
531 else if (handler == modstate->default_handler) { in signal_signal_impl()
574 SIG_IGN -- if the signal is being ignored
575 SIG_DFL -- if the default action for the signal is in effect
576 None -- if an unknown handler is in effect
577 anything else -- the callable Python object used as a handler
626 /* Though being a UNIX, HP-UX does not provide strsignal(3). */ in signal_strsignal_impl()
645 case SIGINT: in signal_strsignal_impl()
744 if (sockfd == (SOCKET_T)(-1) && PyErr_Occurred())
755 if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
792 /* on Windows, a file cannot be set to non-blocking mode */
798 is in non-blocking mode */
810 return PyLong_FromLong(-1);
812 if (fd != -1) {
823 "the fd %i must be in non-blocking mode",
838 "set_wakeup_fd(fd, *, warn_on_full_buffer=True) -> fd\n\
842 The previous fd or -1 is returned.\n\
844 The fd must be non-blocking.");
851 fd = -1;
900 PyErr_SetFromErrno(modstate->itimer_error);
927 PyErr_SetFromErrno(modstate->itimer_error);
952 /* Handle the case where it is a member by adding the signal to
962 if (PySet_Add(result, signum) == -1) {
1088 SIGILL, SIGINT, SIGSEGV, SIGTERM);
1091 SIGINT, SIGSEGV, SIGTERM);
1146 PyStructSequence_SET_ITEM(result, 0, PyLong_FromLong((long)(si->si_signo)));
1147 PyStructSequence_SET_ITEM(result, 1, PyLong_FromLong((long)(si->si_code)));
1154 PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong((long)(si->si_errno)));
1155 PyStructSequence_SET_ITEM(result, 3, PyLong_FromPid(si->si_pid));
1156 PyStructSequence_SET_ITEM(result, 4, _PyLong_FromUid(si->si_uid));
1158 PyLong_FromLong((long)(si->si_status)));
1161 PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
1200 } while (err == -1
1202 if (err == -1)
1239 PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");
1253 if (res != -1)
1268 timeout = deadline - monotonic;
1353 /* List of functions defined in the module -- some of the methoddefs are
1386 alarm() -- cause SIGALRM after a specified time [Unix only]\n\
1387 setitimer() -- cause a signal (described below) after a specified\n\
1389 getitimer() -- get current value of timer [Unix only]\n\
1390 signal() -- set the action for a given signal\n\
1391 getsignal() -- get the signal action for a given signal\n\
1392 pause() -- wait until a signal arrives [Unix only]\n\
1393 default_int_handler() -- default SIGINT handler\n\
1396 SIG_DFL -- used to refer to the system default handler\n\
1397 SIG_IGN -- used to ignore the signal\n\
1398 NSIG -- number of defined signals\n\
1399 SIGINT, SIGTERM, etc. -- signal numbers\n\
1402 ITIMER_REAL -- decrements in real time, and delivers SIGALRM upon\n\
1404 ITIMER_VIRTUAL -- decrements only when the process is executing,\n\
1406 ITIMER_PROF -- decrements both when the process is executing and\n\
1424 return -1; \
1444 #ifdef SIGINT
1445 ADD_INT_MACRO(SIGINT);
1589 func = state->default_handler;
1592 func = state->ignore_handler;
1604 // Install Python SIGINT handler which raises KeyboardInterrupt
1605 PyObject* sigint_func = get_handler(SIGINT);
1606 if (sigint_func == state->default_handler) {
1610 return -1;
1613 set_handler(SIGINT, int_handler);
1615 PyOS_setsig(SIGINT, signal_handler);
1629 modstate->default_handler = state->default_handler; // borrowed ref
1630 modstate->ignore_handler = state->ignore_handler; // borrowed ref
1633 modstate->itimer_error = PyErr_NewException("signal.itimer_error",
1635 if (modstate->itimer_error == NULL) {
1636 return -1;
1641 return -1;
1646 if (PyDict_SetItemString(d, "SIG_DFL", state->default_handler) < 0) {
1647 return -1;
1649 if (PyDict_SetItemString(d, "SIG_IGN", state->ignore_handler) < 0) {
1650 return -1;
1653 if (PyDict_SetItemString(d, "ItimerError", modstate->itimer_error) < 0) {
1654 return -1;
1659 return -1;
1664 if (_Py_IsMainInterpreter(tstate->interp)) {
1666 return -1;
1680 Py_VISIT(modstate->itimer_error);
1688 Py_CLEAR(modstate->itimer_error);
1739 && func != state->default_handler
1740 && func != state->ignore_handler)
1748 if (state->sigint_event != NULL) {
1749 CloseHandle(state->sigint_event);
1750 state->sigint_event = NULL;
1754 Py_CLEAR(state->default_handler);
1755 Py_CLEAR(state->ignore_handler);
1764 if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
1788 * 1 but we have no more signals to handle (Handlers[i].tripped
1796 PyObject *frame = (PyObject *)tstate->frame;
1812 * (see bpo-43406).
1815 if (func == NULL || func == Py_None || func == state->ignore_handler ||
1816 func == state->default_handler) {
1842 /* On error, re-schedule a call to _PyErr_CheckSignalsTstate() */
1844 return -1;
1871 return -1;
1876 if (func != state->ignore_handler && func != state->default_handler) {
1885 (void) PyErr_SetInterruptEx(SIGINT);
1901 // Import _signal to install the Python SIGINT handler
1904 return -1;
1914 * All of the code in this function must only use async-signal-safe functions,
1940 state->default_handler = PyLong_FromVoidPtr((void *)SIG_DFL);
1941 if (state->default_handler == NULL) {
1942 return -1;
1945 state->ignore_handler = PyLong_FromVoidPtr((void *)SIG_IGN);
1946 if (state->ignore_handler == NULL) {
1947 return -1;
1951 /* Create manual-reset event, initially unset */
1952 state->sigint_event = CreateEvent(NULL, TRUE, FALSE, FALSE);
1953 if (state->sigint_event == NULL) {
1955 return -1;
1962 return -1;
1973 return -1;
1986 if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
1990 if (!_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
1994 _Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
2041 /* Returns a manual-reset event which gets tripped whenever
2042 SIGINT is received.
2044 Python.h does not include windows.h so we do cannot use HANDLE
2049 return state->sigint_event;