Skip to content

fix(shell): resolve bash timeout hang when daemon inherits stdio pipes#10

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:haozhe/timeout-bugfix
May 25, 2026
Merged

fix(shell): resolve bash timeout hang when daemon inherits stdio pipes#10
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:haozhe/timeout-bugfix

Conversation

@sailist
Copy link
Copy Markdown
Collaborator

@sailist sailist commented May 25, 2026

Summary

Fixes a bug where the Bash tool'''s timeout would not take effect when a command spawned a detached daemon process that inherited stdio pipes. The agent would hang indefinitely because the process exit promise waited for stdio streams to close, which never happened while the daemon held the pipe file descriptors open.


1. Destroy stdio streams on abort in BashTool

Problem: When a Bash command spawned a detached daemon that inherited stdout/stderr pipes, aborting the shell command did not release those pipes. The daemon kept the file descriptors open, preventing the close event from firing and causing the agent to hang indefinitely.

What was done:

  • Explicitly destroy proc.stdout and proc.stderr in the abort handler inside BashTool to forcibly close the stdio pipes.

2. Use exit instead of close in LocalProcess

Problem: child.on('\''close'\'') waits for all stdio streams to close before resolving the exit promise. If a detached daemon inherits stdio pipes, the close event never fires.

What was done:

  • Changed the event listener from close to exit in LocalProcess so the exit promise resolves as soon as the child process itself terminates, regardless of stdio stream state.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@sailist
Copy link
Copy Markdown
Collaborator Author

sailist commented May 25, 2026

@codex

@sailist sailist force-pushed the haozhe/timeout-bugfix branch from 055a1ca to 7183e78 Compare May 25, 2026 07:42
- destroy stdout/stderr on abort to release stdio pipes held by detached daemons\n- use `exit` instead of `close` event to resolve exit promise
@sailist sailist force-pushed the haozhe/timeout-bugfix branch from 7183e78 to cf73f1f Compare May 25, 2026 07:44
@sailist sailist merged commit 67d3cb8 into MoonshotAI:main May 25, 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.

2 participants