]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100649: Update native_thread_id after fork (gh-100650)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 1 Jan 2023 14:50:56 +0000 (06:50 -0800)
committerGitHub <noreply@github.com>
Sun, 1 Jan 2023 14:50:56 +0000 (06:50 -0800)
Update native_thread_id after fork
(cherry picked from commit d52d4942cfdd52a50f88b87b1ff2a67375dbcf47)

Co-authored-by: Gabriele N. Tornetta <P403n1x87@users.noreply.github.com>
Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst [new file with mode: 0644]
Modules/posixmodule.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst
new file mode 100644 (file)
index 0000000..7ee929a
--- /dev/null
@@ -0,0 +1 @@
+Update the native_thread_id field of PyThreadState after fork.
index 2dfed7c583c4610ad909cfcde5f3fdcd22531923..150bb78cb41c81681a560f9ab45927d88dee887e 100644 (file)
@@ -591,6 +591,10 @@ PyOS_AfterFork_Child(void)
     PyThreadState *tstate = _PyThreadState_GET();
     _Py_EnsureTstateNotNULL(tstate);
 
+#ifdef PY_HAVE_THREAD_NATIVE_ID
+    tstate->native_thread_id = PyThread_get_thread_native_id();
+#endif
+
     status = _PyEval_ReInitThreads(tstate);
     if (_PyStatus_EXCEPTION(status)) {
         goto fatal_error;