diff --git a/packages/cli/src/acp-integration/acpAgent.ts b/packages/cli/src/acp-integration/acpAgent.ts index 777171cca..0cbace59e 100644 --- a/packages/cli/src/acp-integration/acpAgent.ts +++ b/packages/cli/src/acp-integration/acpAgent.ts @@ -91,13 +91,21 @@ export async function runAcpAgent( // Without this, signal handlers registered elsewhere in the CLI // (e.g., stdin raw mode restoration) override the default exit behavior, // causing the ACP process to ignore termination signals. + let shuttingDown = false; const shutdownHandler = () => { + if (shuttingDown) return; + shuttingDown = true; debugLogger.debug('[ACP] Shutdown signal received, closing streams'); try { process.stdin.destroy(); } catch { // stdin may already be closed } + try { + process.stdout.destroy(); + } catch { + // stdout may already be closed + } }; process.on('SIGTERM', shutdownHandler); process.on('SIGINT', shutdownHandler);