]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154352: Fix killing a worker process in regrtest on OpenBSD (GH-154353)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 21 Jul 2026 13:22:20 +0000 (16:22 +0300)
committerGitHub <noreply@github.com>
Tue, 21 Jul 2026 13:22:20 +0000 (13:22 +0000)
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.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Lib/test/libregrtest/run_workers.py

index befdac7ee77f10705f3242b2f1703952b1278bbb..7e6c7fa4cc5507a223040ab1037e0b16819f1151 100644 (file)
@@ -147,9 +147,12 @@ class WorkerThread(threading.Thread):
 
         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"