gh-105716: Update interp->threads.main After Fork (gh-117049)

I missed this in gh-109921.

We also update Py_Exit() to call _PyInterpreterState_SetNotRunningMain(), if necessary.
This commit is contained in:
Eric Snow 2024-03-21 10:06:35 -06:00 committed by GitHub
parent bbee57fa8c
commit 5a76d1be8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 0 deletions

View file

@ -646,6 +646,7 @@ PyOS_AfterFork_Child(void)
PyThreadState *tstate = _PyThreadState_GET();
_Py_EnsureTstateNotNULL(tstate);
assert(tstate->thread_id == PyThread_get_thread_ident());
#ifdef PY_HAVE_THREAD_NATIVE_ID
tstate->native_thread_id = PyThread_get_thread_native_id();
#endif
@ -655,6 +656,9 @@ PyOS_AfterFork_Child(void)
_Py_qsbr_after_fork((_PyThreadStateImpl *)tstate);
#endif
// Ideally we could guarantee tstate is running main.
_PyInterpreterState_ReinitRunningMain(tstate);
status = _PyEval_ReInitThreads(tstate);
if (_PyStatus_EXCEPTION(status)) {
goto fatal_error;