Skip to content

fix: read group liveness and the sentinel pgid from full ps listings - #13

Merged
Martin Bens (SpiGAndromeda) merged 1 commit into
mainfrom
fix/alpine-busybox-compat
Sep 12, 2026
Merged

Martin Bens (SpiGAndromeda) merged 1 commit into
mainfrom
fix/alpine-busybox-compat

Conversation

@SpiGAndromeda

Copy link
Copy Markdown
Collaborator

Closes out the BusyBox follow-up work #12 left open: the Alpine test leg is green and gates merges again.

The defect

BusyBox ships ps and pgrep without selection flags, and its usage errors exit 1 — the same status pgrep uses for "group has no members". On Alpine a cancellation therefore read the failed pgrep -g probe as an already-emptied group, ended the grace period at once and dropped the SIGKILL escalation, so a tool that ignores SIGTERM outlived its own cancellation. The lifeline sentinel's ps -o pgid= -p read failed outright, leaving it no group id to kill once the server was gone.

The fix

Both sites now read a full ps -A -o listing (pid and pgid columns) and filter it in bash — the one shape procps, BSD/macOS and BusyBox ps all share. pgrep is no longer invoked anywhere, so it drops out of the requirements; a ps that itself fails still degrades to the raw kill -0 group check, never to "empty", keeping the safe direction: a probe that cannot answer delays the kill rather than dropping it.

The test harness had the same dependence. Its liveness probes (ps -o state= -p — BusyBox has neither the state keyword nor -p) now share one _mcp_proc_state helper reading a pid=,stat= listing, the fixture process census reads stat=,args=, and the hardcoded /usr/bin/true is resolved with type -P (true lives in /bin on Alpine). The pgrep-cannot-answer regression test became a ps stub that intercepts only the liveness scan's column signature, so the unknown-liveness fallback stays pinned without degrading the harness's own ps reads.

Tolerances removed

With the suite green on Debian, Alpine and macOS alike, the Alpine allowances from #12 are gone: the CI leg no longer runs continue-on-error, scripts/test-linux.sh fails a bare run on an Alpine failure, and the README requirements drop pgrep and the procps caveat for Alpine consumers.

BusyBox ships ps and pgrep without selection flags, and its usage errors exit 1 (the same status pgrep uses for "no members"), so on Alpine a cancellation read the failed pgrep -g probe as an already-emptied group, ended the grace period at once and dropped the SIGKILL escalation. The lifeline sentinel's ps -o pgid= -p read failed outright, leaving it nothing to kill. Both sites now read a full ps -A -o listing (pid and pgid columns) filtered in bash, the one shape procps, BSD and BusyBox ps share, and the SDK no longer invokes pgrep at all. A ps that itself fails still degrades to the raw kill -0 group check, never to "empty", so a probe that cannot answer delays the kill rather than dropping it.

The test harness leaned on the same missing flags. Its liveness probes used ps -o state= -p (BusyBox has neither the state keyword nor -p selection), and one test hardcoded /usr/bin/true, which Alpine does not have. The probes now share one _mcp_proc_state helper reading a pid=,stat= listing, the fixture process census reads stat=,args=, and true is resolved with type -P. The pgrep-cannot-answer regression test became a ps stub that intercepts only the liveness scan's column signature, so the unknown-liveness fallback stays pinned without degrading the harness's own ps reads.

With the suite green on Debian, Alpine and macOS alike, the Alpine failure tolerances are gone. The CI leg gates merges again, scripts/test-linux.sh no longer allows an Alpine failure on bare runs, and the README requirements drop pgrep and the procps caveat.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@SpiGAndromeda
Martin Bens (SpiGAndromeda) merged commit 449acc6 into main Sep 12, 2026
3 checks passed
@SpiGAndromeda
Martin Bens (SpiGAndromeda) deleted the fix/alpine-busybox-compat branch September 13, 2026 10:50
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