Skip to content

fix(core): settle process exit when descendants hold stdio - #49857

Open
alaminopu wants to merge 1 commit into
anomalyco:devfrom
alaminopu:bound-process-exit
Open

alaminopu wants to merge 1 commit into
anomalyco:devfrom
alaminopu:bound-process-exit

Conversation

@alaminopu

@alaminopu alaminopu commented Sep 18, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #49169

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The spawner settled process exit on close, which waits for stdio EOF. A leftover process holding the pipes (detached server, Start-Process on Windows) means EOF never comes, so exitCode, kill() and scope cleanup blocked. The shell tool timeout killed the shell, then hung on that kill.

exit now starts a 1s timer that settles the signal if close hasn't fired. Side effect: sleep 8 & echo started returns ~1s after the shell exits instead of blocking. Likely covers #47350 too.

v2 already has this via #46085. This brings the same behaviour to dev, which 1.18.x releases are cut from (v1.18.31 still has the bug).

How did you verify your code works?

Added spawner and shell tool tests with a detached grandchild holding stdout: 8.4s on dev with timeout: 500, ~1s with the fix. packages/core and packages/opencode suites pass on macOS. Not verified on Windows.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The spawner resolved its exit signal on "close", which waits for stdio EOF.
A descendant that outlives the process and inherits its pipes (for example a
detached server, or Start-Process on Windows) keeps them open, so exitCode,
kill, and scope release blocked until that descendant died. The shell tool
timeout killed the shell on schedule but the call stayed blocked.

Settle from "exit" after a short drain window when "close" has not fired.

Fixes anomalyco#49169
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

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.

bash tool: timeout kills the shell but does not abandon the stdio read — call duration is unbounded

1 participant