Description
When my service receives SIGINT or SIGTERM, it stop consuming new messages and wait for the running flows to complete (graceful shutdown pattern).
However, the signal propagates to the Claude Code subprocess spawned by the Claude Agents SDK, causing it to exit immediately with exit code -2 (SIGINT). This interrupts the in-flight agent task.
Expected Behavior
When the parent process receives a shutdown signal:
Stop accepting new work
Allow the current agent task to complete
Exit cleanly
The Claude subprocess should not terminate immediately.
Is there:
A way to prevent signal propagation to the Claude subprocess?
A graceful shutdown mode?
A recommended pattern for long-running agent workers?