From c94cb681c71e85768b9fa5e020fa58d1b3b86b8e Mon Sep 17 00:00:00 2001 From: Br1an67 <932039080@qq.com> Date: Mon, 2 Mar 2026 01:12:15 +0800 Subject: [PATCH] fix: prevent SIGINT/SIGTERM propagation to Claude subprocess Add start_new_session=True to the open_process call so the Claude CLI subprocess runs in its own process group. This prevents signals like SIGINT and SIGTERM from propagating from the parent process to the subprocess, allowing graceful shutdown patterns where the parent stops accepting new work while the current agent task completes. The SDK already terminates the subprocess explicitly in its close() method, so this change does not affect normal cleanup. --- src/claude_agent_sdk/_internal/transport/subprocess_cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py index 1f0aac58..c1b4a694 100644 --- a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py +++ b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py @@ -373,6 +373,7 @@ async def connect(self) -> None: stderr=stderr_dest, cwd=self._cwd, env=process_env, + start_new_session=True, user=self._options.user, )