summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriele N. Tornetta <P403n1x87@users.noreply.github.com>2023-01-01 14:20:38 (GMT)
committerGitHub <noreply@github.com>2023-01-01 14:20:38 (GMT)
commitd52d4942cfdd52a50f88b87b1ff2a67375dbcf47 (patch)
treecdd6da49d1f2519dd9626350e8ddde48fcd050a3
parente83f88a455261ed53530a960f1514ab7af7d2e82 (diff)
downloadcpython-d52d4942cfdd52a50f88b87b1ff2a67375dbcf47.zip
cpython-d52d4942cfdd52a50f88b87b1ff2a67375dbcf47.tar.gz
cpython-d52d4942cfdd52a50f88b87b1ff2a67375dbcf47.tar.bz2
gh-100649: Update native_thread_id after fork (gh-100650)
Update native_thread_id after fork
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst1
-rw-r--r--Modules/posixmodule.c4
2 files changed, 5 insertions, 0 deletions
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
index 0000000..7ee929a
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst
@@ -0,0 +1 @@
+Update the native_thread_id field of PyThreadState after fork.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 1d9a33a..0d4c179 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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;