From c6395ed0b1b57e3de19d537584ce2c57ea57e4dc Mon Sep 17 00:00:00 2001 From: Stefano Baldo Date: Sat, 30 May 2026 13:08:24 -0300 Subject: [PATCH] fix(server): close Python backend and exit when stdin closes --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 1ddec83..6b2a404 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,6 +64,12 @@ function parseCommandLineArgs(args: string[]) { * Setup graceful shutdown handlers */ function setupGracefulShutdown(server: KiCADMcpServer) { + // Handle stdin close (EOF) when parent process exits + process.stdin.on("close", async () => { + logger.info("process.stdin closed. Shutting down..."); + await shutdownServer(server); + }); + // Handle termination signals process.on("SIGINT", async () => { logger.info("Received SIGINT signal. Shutting down...");