mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
fix: destroy both stdin and stdout on shutdown, guard against duplicate signals
- Close stdout in addition to stdin to prevent hanging writes during shutdown - Add shuttingDown guard to ensure cleanup runs only once Made-with: Cursor
This commit is contained in:
parent
2e6ab6562b
commit
a6e8aec7f4
1 changed files with 8 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue