#ifdef MS_WINDOWS
HANDLE sigint_event;
#endif
- PyTypeObject *siginfo_type;
} signal_state_t;
// State shared by all Python interpreters
#ifdef PYHAVE_ITIMER_ERROR
PyObject *itimer_error;
#endif
+ PyTypeObject *siginfo_type;
} _signal_module_state;
static PyObject *
-fill_siginfo(siginfo_t *si)
+fill_siginfo(_signal_module_state *state, siginfo_t *si)
{
- signal_state_t *state = &signal_global_state;
-
PyObject *result = PyStructSequence_New(state->siginfo_type);
if (!result)
return NULL;
if (err == -1)
return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
- return fill_siginfo(&si);
+ _signal_module_state *state = get_signal_state(module);
+ return fill_siginfo(state, &si);
}
#endif /* #ifdef HAVE_SIGWAITINFO */
}
} while (1);
- return fill_siginfo(&si);
+ _signal_module_state *state = get_signal_state(module);
+ return fill_siginfo(state, &si);
}
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
return -1;
}
#endif
+
+#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
+ modstate->siginfo_type = PyStructSequence_NewType(&struct_siginfo_desc);
+ if (modstate->siginfo_type == NULL) {
+ return -1;
+ }
+#endif
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
- if (PyModule_AddType(m, state->siginfo_type) < 0) {
+ if (PyModule_AddType(m, modstate->siginfo_type) < 0) {
return -1;
}
#endif
static int
_signal_module_traverse(PyObject *module, visitproc visit, void *arg)
{
- _signal_module_state *modstate = get_signal_state(module);
- Py_VISIT(modstate->itimer_error);
+ _signal_module_state *state = get_signal_state(module);
+ Py_VISIT(state->itimer_error);
+ Py_VISIT(state->siginfo_type);
return 0;
}
static int
_signal_module_clear(PyObject *module)
{
- _signal_module_state *modstate = get_signal_state(module);
- Py_CLEAR(modstate->itimer_error);
+ _signal_module_state *state = get_signal_state(module);
+ Py_CLEAR(state->itimer_error);
+ Py_CLEAR(state->siginfo_type);
return 0;
}
Py_CLEAR(state->default_handler);
Py_CLEAR(state->ignore_handler);
- Py_CLEAR(state->siginfo_type);
}
}
#endif
-#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
- state->siginfo_type = PyStructSequence_NewType(&struct_siginfo_desc);
- if (state->siginfo_type == NULL) {
- return -1;
- }
-#endif
-
for (int signum = 1; signum < NSIG; signum++) {
_Py_atomic_store_relaxed(&Handlers[signum].tripped, 0);
}