Skip to content

Commit d0a9bc5

Browse files
gh-100649: Update native_thread_id after fork (gh-100650)
Update native_thread_id after fork (cherry picked from commit d52d494) Co-authored-by: Gabriele N. Tornetta <[email protected]>
1 parent 7ed7127 commit d0a9bc5

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update the native_thread_id field of PyThreadState after fork.

Modules/posixmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ PyOS_AfterFork_Child(void)
591591
PyThreadState *tstate = _PyThreadState_GET();
592592
_Py_EnsureTstateNotNULL(tstate);
593593

594+
#ifdef PY_HAVE_THREAD_NATIVE_ID
595+
tstate->native_thread_id = PyThread_get_thread_native_id();
596+
#endif
597+
594598
status = _PyEval_ReInitThreads(tstate);
595599
if (_PyStatus_EXCEPTION(status)) {
596600
goto fatal_error;

0 commit comments

Comments
 (0)