Skip to content

fix(cli): don't hang Bash tool on detached child stdio - #13297

Open
mrchatam wants to merge 6 commits into
continuedev:mainfrom
mrchatam:fix/12699-detached-child-stdio-hang
Open

mrchatam wants to merge 6 commits into
continuedev:mainfrom
mrchatam:fix/12699-detached-child-stdio-hang

Conversation

@mrchatam

Copy link
Copy Markdown

Description

Fixes #12699.

When a Bash tool command backgrounds or detaches a child that keeps inherited stdio open, Node's close event never fires and the CLI tool call hangs. This change:

  • Spawns Unix tool shells with detached: true (own process group)
  • Resolves the tool call on process exit (after a short stdio flush), not only close
  • Kills the full process group on timeout/cancel (process.kill(-pid))
  • Applies the same spawn/kill behavior in BackgroundJobService
  • Adds regression tests for background-shell and detached-child patterns

Testing

…2699)

Spawn tool shells in their own process group, resolve the tool call on
process exit (after a short stdio flush) instead of waiting for close,
and kill the full process group on timeout/cancel. Background jobs use
the same spawn/kill behavior. Adds regression tests for background and
detached child cases.
@mrchatam
mrchatam requested a review from a team as a code owner September 19, 2026 15:35
@mrchatam
mrchatam requested review from sestinj and removed request for a team September 19, 2026 15:35
@mrchatam

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

TS18047: child.stdout/stderr are typed as nullable; use optional
chaining when attaching and removing data listeners (matches
BackgroundJobService and other spawn call sites).
Place processTree import with other ../util imports after cli.js so
eslint import/order passes.
Avoid empty Vitest suites on Windows while preserving the Unix regression coverage.

This branch has not been deployed

No deployments
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.

Continue hangs after background or detached child-process tool calls

1 participant