fix(bridge): kill full process group on CLI timeout to prevent orphaned subprocesses#466
Open
nlenepveu wants to merge 2 commits intoasheshgoplani:mainfrom
Open
fix(bridge): kill full process group on CLI timeout to prevent orphaned subprocesses#466nlenepveu wants to merge 2 commits intoasheshgoplani:mainfrom
nlenepveu wants to merge 2 commits intoasheshgoplani:mainfrom
Conversation
…ed subprocesses When run_cli times out and kills agent-deck, grandchild processes spawned by agent-deck (e.g. tmux send-keys -l) survive as orphans because SIGKILL does not propagate to children in a different process group. These orphans continue feeding characters into the tmux pane's PTY input buffer, jamming subsequent sends indefinitely. Fix: - start_new_session=True on subprocess.run puts agent-deck in its own process group, isolated from the bridge's group - os.killpg() on TimeoutExpired kills the entire process group, including all grandchildren - Fallback to proc.kill() if the process group is already gone
…roup kill subprocess.run() raises TimeoutExpired without a .proc attribute — exc.proc is only set by Popen.communicate(timeout=). Replace with Popen + communicate(timeout=) so we can reliably kill the process group on timeout.
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.
Problem
When
run_clitimes out, it kills theagent-deckprocess — but any grandchild processes spawned byagent-deck(most notablytmux send-keys -l) survive as orphans. SIGKILL does not propagate to children in a different process group.These orphans continue feeding characters into the tmux pane's PTY input buffer. On a narrow PTY the buffer fills and subsequent
tmux send-keyscalls from the next heartbeat or user message block indefinitely, effectively freezing the conductor until manually killed.Observed failure mode: Bridge and systemd heartbeat both stuck in
tmux send-keys -lfor 2+ days, conductor unreachable, no Telegram/Slack responses.Fix
start_new_session=Trueonsubprocess.runputsagent-deckin its own process group, isolated from the bridgeos.killpg(os.getpgid(proc.pid), signal.SIGKILL)onTimeoutExpiredkills the entire group including all grandchildrenproc.kill()if the process group is already gone (race condition)Test plan
session send --waitto time out → confirm notmux send-keysorphan survives (ps aux | grep send-keys)