[BUG] Bash commands (incl. run_in_background + nohup) killed with SIGHUP (exit 129) at ~5 min on macOS
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)
- Foreground, via a Node runner script (
node precommit-runner.js, which spawnsyarn test:unit). The test step endedFAIL(129)at about 310 s. Lint and build steps earlier in the same run were fine. run_in_background: truewithnohup yarn test:unit > log 2>&1; echo "exit=$?". The task completed withexit=129. The log ended mid-run: every suite so far had PASSED, and there was no Jest summary.- Workaround that works:
(nohup /bin/bash -c "yarn test:unit > log 2>&1; echo \$? > exit-file" </dev/null >/dev/null 2>&1 &), plus a separaterun_in_backgrounduntil [ -f exit-file ]; do sleep 5; donewaiter. An earlier run in the same session with this pattern finished normally (788 suites passed).
Expected
run_in_backgroundtasks run until they finish (or until their own timeout), without receiving SIGHUP.- At minimum,
nohupshould protect the command. It does not, which suggests the whole process group is signalled, or the hangup is re-delivered afternohupsets 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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗