Repository navigation
fix(agentctl): keep the caller's output from the agentd that agentctl starts on Windows - #573
olebhansen-agent wants to merge 4 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
Superseded by the current report. |
|
@olebhansen, this applies to 3060469 ("test(agentctl): pin that agentd leaves the output of a shell that captures agentctl"). Waits for you: which option on the plan to build. The fix here covers a caller that reads agentctl's own output, such as the steps in #467 and the installer. It does not cover a shell that captures agentctl's output, such as PowerShell running Decided on your behalf: the branch is rebased on current Small, open: the challenger found the name Checks: the challenger ran on the analysis and the build. The red team and QA have not run, since the solution they would check isn't settled. CodeRabbit has not reviewed the pull request. Nobody has run the steps in #467 by hand on Windows. |
d5efc6e to
ff518c0
Compare
da3f0f1 to
7c01a68
Compare
|
Rebased on |
…t starts it A script or coding agent that captures agentctl's output reads it to its end. On Windows, the agentd that agentctl starts holds that output open, so the reader waits until agentd exits. The test plays agentctl and agentd with the test binary, and fails on Windows now. The new spawn_detached is the start agentctl uses for agentd, which the next commit moves both of its callers to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… starts on Windows Windows starts a child with every inheritable handle of its parent, and the standard handles agentctl gets from its caller are inheritable. agentd then held agentctl's output open, so a caller reading it to its end waited until agentd exited. agentctl now marks its standard handles not inheritable before it starts agentd. Children started with Stdio::inherit are unaffected, since Rust passes them duplicates it makes inheritable. Win32_Foundation was already enabled for windows-sys by other dependencies; agent now names it, since it uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7c01a68 to
3060469
Compare
…tures agentctl A shell that captures agentctl's output, such as PowerShell running `agentctl get agents | Out-String`, gives agentctl a pipe of its own. On Windows, agentctl also inherits the shell's own output, which whatever runs the shell reads to its end, and the agentd it starts gets that too. The test plays the shell, agentctl and agentd with the test binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
On Windows, a caller that reads agentctl's output to its end waited until agentd exited whenever that agentctl started agentd. Rust starts a child with every inheritable handle of its parent, and the standard handles agentctl gets from its caller are inheritable, so agentd held them open besides the null and log handles it is given.
agentctl now starts agentd through one
agent::local::process::spawn_detached, from bothspawn_daemonand the updater'sstart_daemon. On Windows it first marks agentctl's own standard handles not inheritable. Children started withStdio::inheritare unaffected, since Rust passes them duplicates it makes inheritable for that one start.That does not cover a shell that captures agentctl's output into a pipe of its own, such as PowerShell running
agentctl get agents | Out-String. agentctl then inherits the shell's output as an extra handle, and agentd still gets it. The last commit adds a test for that case, which fails on Windows. Whether to fix it here, with an explicit handle list, or to merge this for the first case alone waits for a decision on the plan.windows-sysnow namesWin32_Foundation, which other dependencies already enable, so the build andCargo.lockare unchanged.Closes #467
Evidence
The tests run the test binary as the caller, as agentctl and as a detached agentd, so that pipes reach agentctl as they do from a shell. The detached child runs only while a file in the test's temporary directory exists, so it stops when the test ends. CI runs them in the
rust / Portable host (Windows x64 / ARM64)jobs.detached_child_leaves_the_callers_outputfails at "test(agentctl): pin that agentd leaves the output of the agentctl that starts it" (run 44630712293, on an earliermain) and passes with the fix (run 44879602845, on currentmain).detached_child_leaves_the_output_of_the_shell_that_runs_the_callerfails with the fix on both Windows jobs in run 44879602845:the detached child held the caller's output open: Elapsed(()).On Linux both pass before and after, since Rust closes every other descriptor in a child.
Risk
🤖 Generated with Claude Code