Skip to content

fix(bash): keep interactive commands from hanging the TUI#264

Merged
yanmxa merged 2 commits into
genai-io:mainfrom
yanmxa:fix/bash-interactive-hang
Jul 2, 2026
Merged

fix(bash): keep interactive commands from hanging the TUI#264
yanmxa merged 2 commits into
genai-io:mainfrom
yanmxa:fix/bash-interactive-hang

Conversation

@yanmxa

@yanmxa yanmxa commented Jul 2, 2026

Copy link
Copy Markdown
Member

Interactive commands run by the Bash tool (an editor, ssh, a password/confirmation prompt) grabbed the parent TUI's controlling terminal and hung until timeout — and the foreground path then only killed bash, leaving the child that held the terminal alive past the deadline.

  • Start bash in a new session (setsid) so /dev/tty access fails fast instead of stealing the TUI's terminal; on timeout/cancel tear down the whole process group, with a WaitDelay backstop for inherited pipes. Foreground now matches the background path.
  • Nudge tools onto their non-interactive path via GIT_TERMINAL_PROMPT=0 and DEBIAN_FRONTEND=noninteractive.
  • Steer the model: the Bash schema notes commands are non-interactive, and the timeout error suggests a non-interactive flag.

yanmxa added 2 commits July 2, 2026 21:18
An interactive command (an editor, ssh, a password/confirmation prompt)
grabbed the parent TUI's controlling terminal and hung until timeout, and
the foreground path then only killed bash — leaving the child that held
the terminal alive past the deadline.

- Start bash in a new session (setsid) so /dev/tty access fails fast
  instead of stealing the TUI's terminal; on timeout/cancel tear down the
  whole process group, with a WaitDelay backstop for inherited pipes
- Nudge tools onto their non-interactive path via GIT_TERMINAL_PROMPT=0
  and DEBIAN_FRONTEND=noninteractive
- Steer the model: the Bash schema notes commands are non-interactive,
  and the timeout error suggests a non-interactive flag

Signed-off-by: Meng Yan <yanmxa@gmail.com>
- A foreground command that backgrounds a child inheriting the output pipe
  (e.g. "./server &") exits 0, but the new WaitDelay then fires and Run
  returns ErrWaitDelay. Treat exit-0 + ErrWaitDelay as success instead of
  reporting a spurious failure.
- os/exec keeps the last of duplicate env keys, so appending
  GIT_TERMINAL_PROMPT/DEBIAN_FRONTEND after os.Environ() overrode a value the
  user set, contrary to the comment. Set each only when unset.

Signed-off-by: Meng Yan <yanmxa@gmail.com>
@yanmxa yanmxa force-pushed the fix/bash-interactive-hang branch from b23dde6 to 3f38349 Compare July 2, 2026 13:18
@yanmxa yanmxa merged commit 6527313 into genai-io:main Jul 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant