[BUG] Bash commands (incl. run_in_background + nohup) killed with SIGHUP (exit 129) at ~5 min on macOS

Status Closed — not planned
Reported on v2.1.280
Maintainer reply None cached
Activity 1 comment · opened Sep 23, 2026 · closed Sep 23, 2026

Summary

Long-running Bash commands that exceed ~5 minutes are killed with SIGHUP (exit 129). This happens with run_in_background: true as well, and wrapping the command in nohup does not prevent it. Only a fully detached launch survives: (nohup bash -c '…' </dev/null >/dev/null 2>&1 &), then polling for a sentinel file.

Related: #84625 (background tasks killed mid-run) and #76461 (sub-agent background processes SIGHUP'd). This report adds that nohup does not help, and gives the ~310 s observation.

Environment

  • Claude Code 2.1.280, CLI, macOS 26.7 (Apple Silicon), shell zsh
  • Auto mode enabled; main agent (not a sub-agent)
  • Workload: a Jest unit suite of about 790 suites that takes about 6 minutes locally

Observations (same session, same day)

  1. Foreground, via a Node runner script (node precommit-runner.js, which spawns yarn test:unit). The test step ended FAIL(129) at about 310 s. Lint and build steps earlier in the same run were fine.
  2. run_in_background: true with nohup yarn test:unit > log 2>&1; echo "exit=$?". The task completed with exit=129. The log ended mid-run: every suite so far had PASSED, and there was no Jest summary.
  3. Workaround that works: (nohup /bin/bash -c "yarn test:unit > log 2>&1; echo \$? > exit-file" </dev/null >/dev/null 2>&1 &), plus a separate run_in_background until [ -f exit-file ]; do sleep 5; done waiter. An earlier run in the same session with this pattern finished normally (788 suites passed).

Expected

  • run_in_background tasks run until they finish (or until their own timeout), without receiving SIGHUP.
  • At minimum, nohup should protect the command. It does not, which suggests the whole process group is signalled, or the hangup is re-delivered after nohup sets up its handler.

Actual

  • The command gets SIGHUP around the 5-minute mark and reports exit 129. Nothing in the tool result shows that the harness killed it, so it looks like a test failure.

Repro (minimal)

# run with run_in_background: true
nohup bash -c 'for i in $(seq 1 400); do sleep 1; done; echo done' ; echo "exit=$?"

Expected: done / exit=0 after about 400 s. Observed with the real workload: exit 129 at about 310 s.

Impact

Pre-commit and test gates look like they failed (exit 129) when no test failed. The agent then has to re-run them with an ad-hoc detach pattern.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗