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

- destroy stdout/stderr on abort to release stdio pipes held by detached daemons\n- use `exit` instead of `close` event to resolve exit promise

Co-authored-by: haozhe.yang <yanghaozhe@moonshot.ai>
This commit is contained in:
Haozhe 2026-05-25 16:12:59 +08:00 committed by GitHub
parent ee7486cb06
commit 67d3cb8ad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -275,6 +275,17 @@ export class BashTool implements BuiltinTool<BashInput> {
/* ignore */
}
}
try {
proc.stdout.destroy();
} catch {
/* ignore */
}
try {
proc.stderr.destroy();
} catch {
/* ignore */
}
};
const onAbort = (): void => {

View file

@ -58,7 +58,7 @@ class LocalProcess implements KaosProcess {
this.pid = child.pid ?? -1;
this._exitPromise = new Promise<number>((resolve, reject) => {
child.on('close', (code: number | null) => {
child.on('exit', (code: number | null) => {
this._exitCode = code ?? -1;
resolve(this._exitCode);
});