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 <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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"