Skip to content

fix: treat killpg EPERM on reported provider groups as exited - #26

Merged
minglong51 merged 1 commit into
mainfrom
fix/pgid-reuse-eperm
Aug 31, 2026
Merged

fix: treat killpg EPERM on reported provider groups as exited#26
minglong51 merged 1 commit into
mainfrom
fix/pgid-reuse-eperm

Conversation

@minglong51

Copy link
Copy Markdown
Owner

Problem

test_provider_probe collector-cleanup tests flake on the macOS CI runner (twice: main 08-28 run 33147669569, PR #25 run 33362589984) with:

PermissionError: [Errno 1] Operation not permitted   # os.killpg
provider_probe.ProbeError: provider-termination-failed
AssertionError: "^collector-termination-forced$" does not match "provider-termination-failed"

A reported provider pgid outlives the group it names: once every member is dead, the id can be recycled by another user's process, and killpg on it returns EPERM. macOS pid randomization makes that reuse fast on a busy runner; Linux's sequential pids explain why only macOS hits it.

Change

The probe spawns provider groups under its own uid, so a group it still owns is always signalable. In the three raw-pgid helpers (_process_group_exists, _signal_process_group, and through them _wait_for_process_group_exit), EPERM now means "the id no longer names our group" — exited — instead of raising provider-termination-failed. The Popen-based _terminate_provider_group keeps its EPERM failure: its leader pid is held un-reaped, so it cannot be recycled.

Verification

  • python3 -m unittest tests.test_provider_probe: 18 OK × 3 runs; full unit group 122 OK
  • Deterministic check with os.killpg mocked to raise EPERM: all three helpers report the group as gone; ESRCH behavior unchanged
  • The flake itself is timing-dependent and cannot be forced; CI history adjudicates

🤖 Generated with Claude Code

https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy

A reported provider pgid outlives the group: once every member is dead,
the id can be recycled by another user's process, and killpg then
returns EPERM. The probe spawns provider groups under its own uid, so a
group it still owns is always signalable; EPERM therefore means the id
no longer names that group. Raising provider-termination-failed here
made collector-cleanup tests flake on the macOS CI runner, where pid
randomization recycles ids quickly. The Popen-based provider path keeps
its EPERM failure: its leader pid is held un-reaped, so it cannot be
recycled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy
@minglong51
minglong51 merged commit 476f745 into main Aug 31, 2026
3 checks passed
@minglong51
minglong51 deleted the fix/pgid-reuse-eperm branch August 31, 2026 17:23
@minglong51 minglong51 mentioned this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant