Repository navigation
run_shell: return when the shell exits, keep backgrounded servers running - #140
Merged
Merged
Conversation
…ning A command that backgrounds a server itself (`python3 -m http.server 8080 &`) left a child holding the stdout pipe, and run_shell waited for that pipe to close: the agent sat out the full timeout (120 s default), then the group kill took the server down, so the next browser call got ERR_CONNECTION_REFUSED. The run now ends when zsh exits. Output already written is collected (short drain); a child still holding the pipe is left running, its later output drained and dropped, and the result says so. Timeout and Stop still kill the whole group. - PipeCollector reads via a dispatch readability handler and holds the handle until EOF (a deallocated handle closed the read end and the server died of SIGPIPE on its next log line). - Lossy UTF-8 decode, so a byte cap can't blank the output. - `python3 -m http.server` joins the auto-background markers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Bug (seen in a Naseem benchmark run): the model ran
… python3 -m http.server 8080 & …inrun_shell. The background server held the stdout pipe open,run_shellwaited for EOF until its 120 s timeout, then killed the process group — server included — so the nextchrome_devtools__new_pagegotERR_CONNECTION_REFUSED.Fix: the run ends when zsh exits, not when the pipe closes.
PipeCollectorreads with a dispatch readability handler and keeps theFileHandlealive until EOF (otherwise the read end closes and the server dies of SIGPIPE on its next log line — caught in the live repro).python3 -m http.serveradded to the auto-background markers.Tests
shellTimesOutEvenWhenOrphanHoldsStdout(it asserted the old behavior) withshellReturnsWhenShellExitsAndLeavesBackgroundChildRunning— failed before the fix (21 s, killed child), passes after (<1 s, child alive).shellTimeoutKillsTheWholeGroup,shellDetectsPython3HTTPServer.python3 -m http.server 8799 & sleep 1; echo upreturns in 1.5 s and three latercurls get the page.🤖 Generated with Claude Code