fix(staged): detach env-capture shell from user TTY#756
Merged
Conversation
`capture_shell_env`/`capture_shell_env_blocking` spawned `$SHELL -ils` inheriting the parent's controlling terminal. The interactive shell then `tcsetpgrp`'d the user's real /dev/tty and, on exit, left the foreground process group pointing at a dead PGID — causing the outer zsh to die with EIO on TTY read after `just dev` had been running. Add `setsid()` via `pre_exec` to both spawn paths so the child runs in a new session with no controlling terminal, matching the canonical pattern in `crates/builderbot-actions/src/executor.rs`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
`tokio::process::Command` exposes `pre_exec` as an inherent unsafe method on Unix, so the `use std::os::unix::process::CommandExt;` line added in 4c51a61 was dead. The sibling sync path still needs the import because `std::process::Command::pre_exec` only exists via the trait. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.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.
Summary
The interactive
$SHELL -ilsspawned for environment capture inherited the staged binary's controlling TTY (the user's real/dev/tty). On exit, the shell couldtcsetpgrpor mutate terminal modes against that TTY, leaving the foreground process group pointing at a dead PGID — which caused the outer zsh to later die with EIO on read ("terminal killed").Fix: call
setsid()inpre_execto detach the spawned shell into its own session with no controlling terminal. Applied to both the async (capture_shell_env) and blocking (capture_shell_env_blocking) paths.Test plan