File indexing completed on 2025-11-19 09:50:50
0001
0002
0003 #ifndef Py_INTERNAL_SIGNAL_H
0004 #define Py_INTERNAL_SIGNAL_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008
0009 #ifndef Py_BUILD_CORE
0010 # error "this header requires Py_BUILD_CORE define"
0011 #endif
0012
0013 #include <signal.h> // NSIG
0014
0015
0016
0017
0018 PyAPI_FUNC(void) _Py_RestoreSignals(void);
0019
0020 #ifdef _SIG_MAXSIG
0021
0022
0023
0024 # define Py_NSIG _SIG_MAXSIG
0025 #elif defined(NSIG)
0026 # define Py_NSIG NSIG
0027 #elif defined(_NSIG)
0028 # define Py_NSIG _NSIG
0029 #elif defined(_SIGMAX)
0030 # define Py_NSIG (_SIGMAX + 1)
0031 #elif defined(SIGMAX)
0032 # define Py_NSIG (SIGMAX + 1)
0033 #else
0034 # define Py_NSIG 64
0035 #endif
0036
0037 #define INVALID_FD (-1)
0038
0039 struct _signals_runtime_state {
0040 struct {
0041
0042 int tripped;
0043 PyObject* func;
0044 } handlers[Py_NSIG];
0045
0046 volatile struct {
0047 #ifdef MS_WINDOWS
0048
0049
0050 volatile int fd;
0051 #elif defined(__VXWORKS__)
0052 int fd;
0053 #else
0054 sig_atomic_t fd;
0055 #endif
0056
0057 int warn_on_full_buffer;
0058 #ifdef MS_WINDOWS
0059 int use_send;
0060 #endif
0061 } wakeup;
0062
0063
0064
0065 int is_tripped;
0066
0067
0068 PyObject *default_handler;
0069 PyObject *ignore_handler;
0070
0071 #ifdef MS_WINDOWS
0072
0073
0074 void *sigint_event;
0075 #endif
0076
0077
0078
0079 int unhandled_keyboard_interrupt;
0080 };
0081
0082 #ifdef MS_WINDOWS
0083 # define _signals_WAKEUP_INIT \
0084 {.fd = INVALID_FD, .warn_on_full_buffer = 1, .use_send = 0}
0085 #else
0086 # define _signals_WAKEUP_INIT \
0087 {.fd = INVALID_FD, .warn_on_full_buffer = 1}
0088 #endif
0089
0090 #define _signals_RUNTIME_INIT \
0091 { \
0092 .wakeup = _signals_WAKEUP_INIT, \
0093 }
0094
0095
0096
0097 PyAPI_FUNC(int) _PyOS_IsMainThread(void);
0098
0099 #ifdef MS_WINDOWS
0100
0101
0102 PyAPI_FUNC(void*) _PyOS_SigintEvent(void);
0103 #endif
0104
0105 #ifdef __cplusplus
0106 }
0107 #endif
0108 #endif