@@ -136,7 +136,6 @@ typedef struct {
136
136
#ifdef MS_WINDOWS
137
137
HANDLE sigint_event ;
138
138
#endif
139
- PyTypeObject * siginfo_type ;
140
139
} signal_state_t ;
141
140
142
141
// State shared by all Python interpreters
@@ -152,6 +151,7 @@ typedef struct {
152
151
#ifdef PYHAVE_ITIMER_ERROR
153
152
PyObject * itimer_error ;
154
153
#endif
154
+ PyTypeObject * siginfo_type ;
155
155
} _signal_module_state ;
156
156
157
157
@@ -1139,10 +1139,8 @@ static PyStructSequence_Desc struct_siginfo_desc = {
1139
1139
1140
1140
1141
1141
static PyObject *
1142
- fill_siginfo (siginfo_t * si )
1142
+ fill_siginfo (_signal_module_state * state , siginfo_t * si )
1143
1143
{
1144
- signal_state_t * state = & signal_global_state ;
1145
-
1146
1144
PyObject * result = PyStructSequence_New (state -> siginfo_type );
1147
1145
if (!result )
1148
1146
return NULL ;
@@ -1206,7 +1204,8 @@ signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
1206
1204
if (err == -1 )
1207
1205
return (!async_err ) ? PyErr_SetFromErrno (PyExc_OSError ) : NULL ;
1208
1206
1209
- return fill_siginfo (& si );
1207
+ _signal_module_state * state = get_signal_state (module );
1208
+ return fill_siginfo (state , & si );
1210
1209
}
1211
1210
1212
1211
#endif /* #ifdef HAVE_SIGWAITINFO */
@@ -1274,7 +1273,8 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
1274
1273
}
1275
1274
} while (1 );
1276
1275
1277
- return fill_siginfo (& si );
1276
+ _signal_module_state * state = get_signal_state (module );
1277
+ return fill_siginfo (state , & si );
1278
1278
}
1279
1279
1280
1280
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
@@ -1661,8 +1661,15 @@ signal_module_exec(PyObject *m)
1661
1661
return -1 ;
1662
1662
}
1663
1663
#endif
1664
+
1665
+ #if defined(HAVE_SIGWAITINFO ) || defined(HAVE_SIGTIMEDWAIT )
1666
+ modstate -> siginfo_type = PyStructSequence_NewType (& struct_siginfo_desc );
1667
+ if (modstate -> siginfo_type == NULL ) {
1668
+ return -1 ;
1669
+ }
1670
+ #endif
1664
1671
#if defined(HAVE_SIGWAITINFO ) || defined(HAVE_SIGTIMEDWAIT )
1665
- if (PyModule_AddType (m , state -> siginfo_type ) < 0 ) {
1672
+ if (PyModule_AddType (m , modstate -> siginfo_type ) < 0 ) {
1666
1673
return -1 ;
1667
1674
}
1668
1675
#endif
@@ -1683,16 +1690,18 @@ signal_module_exec(PyObject *m)
1683
1690
static int
1684
1691
_signal_module_traverse (PyObject * module , visitproc visit , void * arg )
1685
1692
{
1686
- _signal_module_state * modstate = get_signal_state (module );
1687
- Py_VISIT (modstate -> itimer_error );
1693
+ _signal_module_state * state = get_signal_state (module );
1694
+ Py_VISIT (state -> itimer_error );
1695
+ Py_VISIT (state -> siginfo_type );
1688
1696
return 0 ;
1689
1697
}
1690
1698
1691
1699
static int
1692
1700
_signal_module_clear (PyObject * module )
1693
1701
{
1694
- _signal_module_state * modstate = get_signal_state (module );
1695
- Py_CLEAR (modstate -> itimer_error );
1702
+ _signal_module_state * state = get_signal_state (module );
1703
+ Py_CLEAR (state -> itimer_error );
1704
+ Py_CLEAR (state -> siginfo_type );
1696
1705
return 0 ;
1697
1706
}
1698
1707
@@ -1760,7 +1769,6 @@ _PySignal_Fini(void)
1760
1769
1761
1770
Py_CLEAR (state -> default_handler );
1762
1771
Py_CLEAR (state -> ignore_handler );
1763
- Py_CLEAR (state -> siginfo_type );
1764
1772
}
1765
1773
1766
1774
@@ -1968,13 +1976,6 @@ _PySignal_Init(int install_signal_handlers)
1968
1976
}
1969
1977
#endif
1970
1978
1971
- #if defined(HAVE_SIGWAITINFO ) || defined(HAVE_SIGTIMEDWAIT )
1972
- state -> siginfo_type = PyStructSequence_NewType (& struct_siginfo_desc );
1973
- if (state -> siginfo_type == NULL ) {
1974
- return -1 ;
1975
- }
1976
- #endif
1977
-
1978
1979
for (int signum = 1 ; signum < NSIG ; signum ++ ) {
1979
1980
_Py_atomic_store_relaxed (& Handlers [signum ].tripped , 0 );
1980
1981
}
0 commit comments