[BUG] Background Bash tasks (run_in_background) killed by external SIGTERM mid-execution, only after a session runs long

Open 💬 0 comments Opened Jul 12, 2026 by friction823

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When Claude runs a long command (e.g. a ~15-20 min native iOS build via eas build --local) using the background Bash tool (run_in_background: true), the process gets killed by an external SIGTERM signal partway through — the tool itself logs it catching a termination signal before exiting, it's not a crash or a build error.

The first several background tasks in a session complete normally. After the session has been running for a while (many turns/tool calls), background tasks start getting killed instead, consistently, across multiple retries — each killed at a progressively different point in execution, ruling out a fixed per-task timeout.

Running the identical command directly in a normal Terminal window (not through Claude) completes successfully every time, which rules out the command, the project, or the machine as the cause.

What Should Happen?

A background Bash task started with run_in_background: true should run to completion regardless of how long the current session has been active, or how many conversation turns/scheduled wakeups occur while it's running.

Error Messages/Logs

[ABORT] Received termination signal.
[ABORT] Received termination signal.
(this is what the build tool printed right before exiting — paste your own tool's log lines if different)

Steps to Reproduce

  1. Start a Claude Code session and let it run for an extended period (many tool calls / turns).
  2. Ask Claude to run a long-running command (10+ minutes) via the background Bash tool.
  3. Observe that early in the session, background tasks complete normally.
  4. Later in the same session, background tasks are killed by an external SIGTERM before completing, even though the identical command run manually (outside Claude) completes fine.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.207 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • The first 3 background tasks in the session succeeded normally (10-20 min native builds each).
  • Starting with the 4th, 3 consecutive background tasks were killed, each at a progressively later point in execution (early stage → mid-build linking stage → final archive/export stage) — this rules out a fixed timeout, since a timeout would kill at a consistent elapsed time regardless of progress.
  • Checked pmset -g log for system sleep/wake events at each failure timestamp — no sleep event correlated with any of the kills, ruling out the Mac going to sleep.
  • The exact same command run directly in a normal Terminal window (outside Claude Code) completed successfully on the first attempt, ruling out the command/project/machine as the cause.
  • Each killed process logged catching an external termination signal before exiting (e.g. "Received termination

signal") rather than crashing or timing out internally — this was an external SIGTERM, not a failure in the command itself.

  • My working theory: something ties background task survival to overall session length/turn count rather than per-task duration, and once a session crosses some threshold, background tasks stop surviving between conversation turns. Not confirmed, just the pattern that fits the evidence.

View original on GitHub ↗