mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-02 13:40:46 +00:00
Merge pull request #2472 from QwenLM/fix/acp-connection-state-cleanup-1780
fix: clean up ACP connection state when child process exits
This commit is contained in:
commit
572fa81f38
3 changed files with 199 additions and 9 deletions
|
|
@ -87,7 +87,33 @@ export async function runAcpAgent(
|
|||
stream,
|
||||
);
|
||||
|
||||
// Handle SIGTERM/SIGINT for graceful shutdown.
|
||||
// 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);
|
||||
|
||||
await connection.closed;
|
||||
|
||||
process.off('SIGTERM', shutdownHandler);
|
||||
process.off('SIGINT', shutdownHandler);
|
||||
}
|
||||
|
||||
function toStdioServer(server: McpServer): McpServerStdio | undefined {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue