claude-code - 💡(How to fix) Fix claude --print long-running sessions hang post-completion until SIGKILL (cc 2.1.133.6c0)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  • 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.

Fix Action

Fix / Workaround

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]

Workaround currently in place

Code Example

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]
RAW_BUFFERClick to expand / collapse

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING