claude --print long-running sessions hang post-completion until SIGKILL (cc 2.1.133.6c0)

Resolved 💬 4 comments Opened May 15, 2026 by yaaarning26 Closed Jun 14, 2026

Environment

  • Claude Code version: 2.1.133.6c0 (per debug-file attribution header x-anthropic-billing-header: cc_version=2.1.133.6c0; cc_entrypoint=sdk-cli)
  • macOS Darwin 25.3.0
  • Bundled Bun runtime
  • Mode: claude --print --dangerously-skip-permissions --debug-file <path> "<prompt>"
  • Parent process: launchd-supervised job-queue worker, polls every 30s

Issue

claude --print consistently fails to exit cleanly after long-running jobs. The work itself completes (summary written, tools called, result produced), but the process keeps running until macOS kills it with SIGKILL (exit 137) after ~5–6 minutes total wall-clock.

Bash captures this as <script>: line N: PID Killed: 9 claude --print ... and a typical worker treats it as a failed job — when in fact the job completed and the summary file on disk says status: "completed". The result is real, completed work being reported as failed by the supervisor.

Reproduction pattern

For TWO consecutive jobs in the same session:

  • Job A: started 15:25:38Z, SIGKILL at 15:31:19Z (5m41s wall clock). Claude's final stdout was a clean "Job completed" report with summary path + working blob URL. Summary file on disk had status: "completed". Then SIGKILL.
  • Job B: started 15:34:19Z, SIGKILL at 15:39:50Z (5m31s wall clock). Claude was mid-recovery from an MCP tool error, actively making API requests + tool calls right up to the kill.

Both jobs had ~20 MCP tool calls (a macos-automator MCP driving Pixelmator Pro Creator Studio) + a handful of Bash calls. Sustained ~500MB+ RAM per Activity Monitor.

Debug log signature near SIGKILL

15:39:49.547 [INFO] [Stall] tool_dispatch_end tool=mcp__macos-automator__execute_script outcome=ok
15:39:49.549 [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
15:39:49.551 [DEBUG] [API:auth] OAuth token check starting
15:39:49.552 [DEBUG] [API REQUEST] /v1/messages
[~1s later: SIGKILL, no further log entries]

No idle-stall pattern; Claude is actively in an API-request loop right up to the kill. No graceful-shutdown signal handling visible.

Request

  1. Graceful exit after task completion in --print mode — if Claude has produced its final response, it should exit 0 rather than holding the process open and being vulnerable to OS kill.
  2. Signal handling — trap SIGTERM/SIGINT to write a final state marker, so supervisors can distinguish "task completed, killed during idle" from "task failed mid-execution."

Workaround currently in place

Worker shell now uses the summary file Claude writes as source-of-truth, not exit code. But this requires every consumer to know about the bug and write defensive code; a graceful-exit fix in Claude Code itself would let supervisors trust exit codes again.

Full debug logs (~50KB each) available on request.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗