mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
bpo-35724: Explicitly require the main interpreter for signal-handling. (GH-11530)
Ensure that the main interpreter is active (in the main thread) for signal-handling operations. This is increasingly relevant as people use subinterpreters more. https://bugs.python.org/issue35724
This commit is contained in:
parent
06babb2422
commit
64d6cc826d
4 changed files with 39 additions and 9 deletions
|
@ -379,9 +379,16 @@ handle_signals(void)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Ensure that the thread isn't currently running some other
|
||||
* interpreter.
|
||||
*/
|
||||
if (_PyInterpreterState_GET_UNSAFE() != _PyRuntime.interpreters.main) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
UNSIGNAL_PENDING_SIGNALS();
|
||||
if (PyErr_CheckSignals() < 0) {
|
||||
if (_PyErr_CheckSignals() < 0) {
|
||||
SIGNAL_PENDING_SIGNALS(); /* We're not done yet */
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue