Skip to content

Kill analyzer process groups on deadline#22

Merged
haasonsaas merged 1 commit into
mainfrom
hardening/process-group-termination
Jul 18, 2026
Merged

Kill analyzer process groups on deadline#22
haasonsaas merged 1 commit into
mainfrom
hardening/process-group-termination

Conversation

@haasonsaas

Copy link
Copy Markdown
Collaborator

Summary

  • Deferred since the first adapter review: both exec sites used CommandContext's default kill, which signals only the direct child. A timed-out room-semgrep left its semgrep-core scan running (the adapter passes -timeout 0, so nothing else stops it), and a timed-out provider in roomd left any scanner it spawned orphaned.
  • Both children now run in their own process group (Setpgid) with a custom Cancel that SIGKILLs the group; ESRCH is tolerated so a clean early exit never masks the real result. Non-unix builds keep the previous direct kill behind a build-tagged helper (internal/analyzer stays portable; cmd/room-semgrep is already Linux-only).
  • Also wraps the startup config-read error with its underlying cause (review follow-up from Read Semgrep config without following symlinks #20).

Test plan

  • New: provider/adapter scripts that spawn a sleep 60 grandchild are group-killed on deadline — the grandchild's pid reaches ESRCH within 2s, at both exec sites (TestAdapterKillsSemgrepProcessGroup, TestExternalAnalyzerKillsProviderProcessGroup)
  • go test ./... clean (unix-tagged helper files compile both sides)
  • ROOM_SEMGREP_CORE=… go test -tags=semgrep_integration ./cmd/room-semgrep — real semgrep-core 1.139.0 suite passes through the new exec path

Both exec sites used CommandContext's default kill, which signals only
the direct child: a timed-out room-semgrep left its semgrep-core scan
running (the adapter passes -timeout 0, so nothing else stops it), and
a timed-out provider left any scanner it spawned orphaned. Run each
child in its own process group and SIGKILL the group on cancel.
Non-unix builds keep the previous direct kill. Also wrap the startup
config-read error with its cause.
@haasonsaas
haasonsaas merged commit ea07f53 into main Jul 18, 2026
4 checks passed
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