https://github.com/python/cpython/commit/9ee705ffa8041d5f6b44178a583114a4fa40ad73
commit: 9ee705ffa8041d5f6b44178a583114a4fa40ad73
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-07-21T17:29:47+03:00
summary:

[3.14] gh-154352: Fix killing a worker process in regrtest on OpenBSD 
(GH-154353) (GH-154361)

os.getsid() is only allowed for a process in the same session on
OpenBSD.  Worker processes are started in their own session, so the
failure means that the process group can be killed.
(cherry picked from commit bfd774d61eeb384b74380deb1fc5b726decba75e)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>

files:
M Lib/test/libregrtest/run_workers.py

diff --git a/Lib/test/libregrtest/run_workers.py 
b/Lib/test/libregrtest/run_workers.py
index 424085a0050eb59..4458e160705bca7 100644
--- a/Lib/test/libregrtest/run_workers.py
+++ b/Lib/test/libregrtest/run_workers.py
@@ -147,9 +147,12 @@ def _kill(self) -> None:
 
         use_killpg = USE_PROCESS_GROUP
         if use_killpg:
-            parent_sid = os.getsid(0)
-            sid = os.getsid(popen.pid)
-            use_killpg = (sid != parent_sid)
+            try:
+                use_killpg = (os.getsid(popen.pid) != os.getsid(0))
+            except PermissionError:
+                # On OpenBSD getsid() is only allowed for a process in the
+                # same session, so the failure means that it is not.
+                use_killpg = True
 
         if use_killpg:
             what = f"{self} process group"

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to