refactor: unify SIGINT/SIGTERM forwarders and add SIGHUP handling#152
Merged
refactor: unify SIGINT/SIGTERM forwarders and add SIGHUP handling#152
Conversation
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/sandbox/sigproxy_test.go">
<violation number="1" location="internal/sandbox/sigproxy_test.go:60">
P2: Avoid fixed `time.Sleep` synchronization in these tests; wait deterministically for the queued signals to be consumed (with a timeout) before asserting or stopping the goroutine.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The outer
fenceand the argv-mode runner had two near-duplicate signal forwarders that diverged subtly. Extract the shared pattern into a singleSignalForwarder(one place to reason about, one place to test) with aPgrpBroadcastflag and anOnEscalatecallback making the divergence explicit. Both forwarders now also catchSIGHUP, so closing the terminal triggers clean teardown instead of relying onbwrap --die-with-parent.Changes
internal/sandbox/sigproxy.go:SignalForwarderwith idempotent stop, 1st/2nd/3rd-signal escalation, optional pgrp-broadcast, optionalOnEscalatehook.killProcessGrouplives here now.cmd/fence/main.go:startCommandWithSignalProxyis now an 8-line wrapper.internal/sandbox/runtime_exec_argv_linux.go:startLinuxArgvExecSignalForwarderis now a wrapper withPgrpBroadcast: true, OnEscalate: shutdown.Begin.internal/sandbox/sigproxy_test.go: 8 unit tests; the dispatch loop is exposed asrun(sigChan, done)so tests drive signals deterministically without the global OS handler.Behavior changes
Process.Kill()s on 2nd signal (no pgrp broadcast) - bwrap isn't always in its own pgrp there. Pgrp-broadcast on the outer fence is deferred to a follow-up.