From b8c7ff982144dc0057686c8a50e53446a7287db4 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 21 Jul 2026 16:30:04 +0200 Subject: [PATCH] [3.15] gh-154352: Fix killing a worker process in regrtest on OpenBSD (GH-154353) (GH-154360) 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 Co-authored-by: Claude Opus 4.8 --- Lib/test/libregrtest/run_workers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/test/libregrtest/run_workers.py b/Lib/test/libregrtest/run_workers.py index 424085a0050e..4458e160705b 100644 --- a/Lib/test/libregrtest/run_workers.py +++ b/Lib/test/libregrtest/run_workers.py @@ -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" -- 2.47.3