Skip to content

regrtest fails to kill a worker process on OpenBSD #154352

Description

@serhiy-storchaka

Bug report

When regrtest has to kill a worker process on OpenBSD — on timeout, or on Ctrl-C — it fails with PermissionError instead, and the whole run ends with a worker bug:

Warning --   File "Lib/test/libregrtest/run_workers.py", line 204, in _run_process
Warning --     self._kill()
Warning --   File "Lib/test/libregrtest/run_workers.py", line 151, in _kill
Warning --     sid = os.getsid(popen.pid)
Warning -- PermissionError: [Errno 1] Operation not permitted
== Tests result: FAILURE, WORKER BUG ==

_kill() compares the session of the worker with its own to decide whether to kill the whole process group:

        if use_killpg:
            parent_sid = os.getsid(0)
            sid = os.getsid(popen.pid)
            use_killpg = (sid != parent_sid)

But POSIX allows getsid() to fail with EPERM if the process is not in the same session as the caller, and OpenBSD does exactly that. Worker processes are started with start_new_session=True, so they are never in the same session:

start_new_session=False -> sid=96067 (mine=96067)
start_new_session=True  -> OSError errno=1 Operation not permitted

The error therefore answers the very question being asked: the worker is in a different session, so its process group can be killed.

Since this runs on every kill, killing a worker has never worked on OpenBSD since process groups were introduced in bpo-38502. Both --timeout and Ctrl-C take the whole run down instead of stopping the single test, which is the opposite of what that machinery is for. test_regrtest fails for this reason.

The comparison cannot simply be dropped: tests that need a TTY are deliberately started without a new session (NEED_TTY), and killing their process group would kill regrtest itself.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesOS-unsupportedtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions