]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100649: Update native_thread_id after fork (gh-100650)
authorGabriele N. Tornetta <P403n1x87@users.noreply.github.com>
Sun, 1 Jan 2023 14:20:38 +0000 (14:20 +0000)
committerGitHub <noreply@github.com>
Sun, 1 Jan 2023 14:20:38 +0000 (23:20 +0900)
Update native_thread_id after fork

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 1d9a33ab7bc9098a68b8e44674d137f5b19bd642..0d4c179368ceac15f4100e30d89f74e164af8bb0 100644 (file)
@@ -595,6 +595,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;