Skip to content

Commit b8c7ff9

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[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 bfd774d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 682610d commit b8c7ff9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/test/libregrtest/run_workers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,12 @@ def _kill(self) -> None:
147147

148148
use_killpg = USE_PROCESS_GROUP
149149
if use_killpg:
150-
parent_sid = os.getsid(0)
151-
sid = os.getsid(popen.pid)
152-
use_killpg = (sid != parent_sid)
150+
try:
151+
use_killpg = (os.getsid(popen.pid) != os.getsid(0))
152+
except PermissionError:
153+
# On OpenBSD getsid() is only allowed for a process in the
154+
# same session, so the failure means that it is not.
155+
use_killpg = True
153156

154157
if use_killpg:
155158
what = f"{self} process group"

0 commit comments

Comments
 (0)