From e22d55974d088b338a6f8297b41e387a8deeab52 Mon Sep 17 00:00:00 2001 From: Kalvin Chau Date: Thu, 9 Jan 2025 15:50:49 -0800 Subject: [PATCH 1/2] feat: set process_group(0) on stdio systems to avoid ctrl-c handling --- crates/mcp-client/src/transport/stdio.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/mcp-client/src/transport/stdio.rs b/crates/mcp-client/src/transport/stdio.rs index fb77a2b1e..3c3d62cb5 100644 --- a/crates/mcp-client/src/transport/stdio.rs +++ b/crates/mcp-client/src/transport/stdio.rs @@ -120,6 +120,7 @@ impl StdioTransport { .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::inherit()) .kill_on_drop(true) + .process_group(0) // don't inherit signal handling from parent process .spawn() .map_err(|e| Error::Other(e.to_string()))?; From ae248b2e19e86fa3b07cd641ced269177691ebf2 Mon Sep 17 00:00:00 2001 From: Kalvin Chau Date: Thu, 9 Jan 2025 16:06:54 -0800 Subject: [PATCH 2/2] docs: add comment explaining 0 value in process_group(0) --- crates/mcp-client/src/transport/stdio.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/mcp-client/src/transport/stdio.rs b/crates/mcp-client/src/transport/stdio.rs index 3c3d62cb5..c983342bb 100644 --- a/crates/mcp-client/src/transport/stdio.rs +++ b/crates/mcp-client/src/transport/stdio.rs @@ -120,6 +120,7 @@ impl StdioTransport { .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::inherit()) .kill_on_drop(true) + // 0 sets the process group ID equal to the process ID .process_group(0) // don't inherit signal handling from parent process .spawn() .map_err(|e| Error::Other(e.to_string()))?;