[Bug]: Claude sessions are killed every TMOUT seconds when the host sets the standard bash TMOUT hardening variable
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
Server / Claude provider (process group watcher)
Summary
On Linux hosts that set the bash TMOUT variable (a standard shell-hardening control), every Claude Code session started by t3 serve is killed with SIGTERM (exit code 143) exactly TMOUT seconds after it starts.
The cause is the process-group watcher in CLAUDE_GROUP_WATCH_SCRIPT:
read -r _ <&4 || exit 1
exec 4<&-
{ trap '' TERM; read -r _ <&3; kill -TERM 0; sleep 5; kill -KILL 0; } </dev/null >/dev/null 2>&1 &
cd -P -- "$1" || exit 125
shift
exec "$@" 3<&-
The background block relies on read -r _ <&3 blocking until t3 serve closes fd 3. In GNU bash, TMOUT also applies to the read builtin in non-interactive shells: when it is set, read returns with status 142 after TMOUT seconds. The script does not check why read returned, so a timeout is treated as "parent is gone" and the whole Claude process group is killed.
TMOUT comes from the environment t3 serve was started in. Setting it in /etc/profile (or /etc/profile.d/*.sh) is an industry-standard hardening control: CIS Benchmarks for RHEL/CentOS/Ubuntu ("ensure default user shell timeout is configured", ≤ 900 s), DISA STIG session-inactivity rules, PCI DSS idle-session requirements and many corporate/regulatory baselines (e.g. China's MLPS 2.0 "login timeout auto-logout") are commonly implemented exactly this way. On hosts without a systemd user manager, long-running services are typically started from a login shell and inherit it, so any such deployment hits this.
Steps to reproduce
- On a Linux host where
/bin/shis GNU bash, startt3 servefrom a login shell that hasTMOUTexported (e.g.export TMOUT=1800in/etc/profile). - Start a Claude Code thread and keep it running past
TMOUTseconds. - The Claude process exits with code 143 at exactly
TMOUTseconds after it was spawned; the thread run fails and has to restart.
Minimal repro of the underlying behaviour (fd 3 is an open pipe that never closes during the test):
( exec 3< <(sleep 5); TMOUT=1 /bin/sh -c 'read -r _ <&3; echo "read returned $?"' )
# prints: read returned 142 (after ~1 s)
( exec 3< <(sleep 3); env -u TMOUT /bin/sh -c 'read -r _ <&3; echo "read returned $?"' )
# blocks until the pipe closes (~3 s), then prints 1
Expected behavior
The watcher only kills the Claude process group when t3 serve actually exits (fd 3 reaches EOF). Inherited shell timeouts must not affect long-running provider sessions.
Actual behavior
Claude Code sessions are terminated every TMOUT seconds. With TMOUT=1800 we observed seven consecutive SIGTERMs, each 1797–1802 s after the session's process start (spawn → exit with code 143), always in the same thread; sub-agents running inside the session are lost with it.
Impact
High for affected deployments: no Claude Code session can live longer than TMOUT, so long-running tasks (builds, background agents, waiting on CI) are repeatedly interrupted. Only the Claude provider is affected, since it is the only provider using this watcher. It is easy to misdiagnose (it looks like an OOM kill or a crash).
Suggested fix
Any of:
- Clear the variable inside the watcher: prefix the script with
unset TMOUT(or spawn/bin/shwithTMOUTremoved from its environment). - Only clean up on EOF: re-enter the
readloop when it returns with status > 128 (timeout/signal), e.g.until read -r _ <&3; [ $? -le 128 ]; do :; done. - Avoid shell
readfor liveness detection (e.g. detect the pipe close from the Node side or use a primitive that is not affected byTMOUT).
Workaround for users: unset TMOUT in whatever launches t3 serve, then restart it.
Version or commit
t3 runtime 0.1.11
Environment
Linux x86_64 (RHEL/CentOS-family, kernel 4.18), /bin/sh → GNU bash 4.4.19, no systemd user manager (t3 service install unavailable), t3 serve started by a bash supervisor script from a login shell; Claude Code provider.
Logs or stack traces
WARN: orchestration-v2.claude-query-stream-failed
[cause]: Error: Claude Code process exited with code 143
at vk.getProcessExitError (.../t3/runtime/versions/0.1.11/t3:360219:15)
at ChildProcess._handle.onexit (node:internal/child_process:323:12)
I tried to reproduce this on the current build and could not.
Commit d1a6c35f73 (origin/main). Code check: apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts:415 still has the reported CLAUDE_GROUP_WATCH_SCRIPT. Its background block { trap '' TERM; read -r _ <&3; kill -TERM 0; ... } treats any return from read as "the server is gone". spawnClaudeProcessGroup runs it with /bin/sh -c and options.env, which is the server's environment, so an exported TMOUT reaches the script. This VM's /bin/sh is dash, which ignores TMOUT. To match the reporter's host I made a private mount namespace with bash bind-mounted over /bin/sh (sudo unshare -m, mount --make-rprivate /, mount --bind /usr/bin/bash /bin/sh, then dropped back to the normal user with setpriv). There I ran the reporter's minimal case: ( exec 3< <(sleep 5); TMOUT=1 /bin/sh -c 'read -r _ <&3; echo read returned $?' ) printed read returned 142 after about 1 s, while fd 3 was still open. That is the condition that sends SIGTERM to the Claude process group, which matches the reporter's exit code 143. I did not run the end-to-end check through spawnClaudeProcessGroup: the worktree checkout finished only after I had stopped. I had drafted a test for ClaudeAgentSdkQueryRunner.test.ts (spawn a fake CLI running sleep 2 with env TMOUT=1, then assert it exits 0 null rather than by SIGTERM) but did not run it, commit it or push it. That test can only fail on main where /bin/sh is bash; on dash-based CI (Ubuntu) it passes on main. A live Claude session was not possible: the VM has no first-party Claude sign-in. The worktree and scratch directory have been removed.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
Reproducing this end-to-end on 0.1.13 (latest), with the exact steps and version you asked for.
- T3 Code 0.1.13, server started 2026-11-27T04:14:39Z, Linux x64,
claudeAgent, Claude Code 2.1.293 /bin/shis bash 4.4.19;/etc/profileexportsTMOUT=1800; the runningt3 servehasTMOUT=1800in/proc/<pid>/environ- 0.1.13 still has
CLAUDE_GROUP_WATCH_SCRIPTwithread -r _ <&3(ClaudeAdapterV2.ts:420-423); current main has the same at:428-431
Eight failed runs since 0.1.13, provider turn durations 1800.674–1802.847 s:
| provider turn start (UTC) | provider turn end (UTC) | duration |
|---|---|---|
| 2026-11-27T04:18:54.102Z | 2026-11-27T04:48:55.055Z | 30:00.953 |
| 2026-11-27T07:17:24.719Z | 2026-11-27T07:47:25.878Z | 30:01.159 |
| 2026-11-27T07:47:26.276Z | 2026-11-27T08:17:26.950Z | 30:00.674 |
| 2026-11-27T08:30:06.298Z | 2026-11-27T09:00:07.451Z | 30:01.153 |
| 2026-11-27T13:23:56.146Z | 2026-11-27T13:53:57.231Z | 30:01.085 |
| 2026-11-27T14:48:07.767Z | 2026-11-27T15:18:08.843Z | 30:01.076 |
| 2026-11-30T08:42:30.339Z | 2026-11-30T09:12:31.073Z | 30:00.734 |
| 2026-12-01T05:41:13.220Z | 2026-12-01T06:11:14.042Z | 30:00.822 |
All are ordinary startTurn runs (attempt reason initial; message not /compact), so #41490 is unrelated.
Latest run: provider turn started 2026-12-01T05:41:13.220Z; provider events still arriving at 06:11:13.321–13.344Z (user, tool_result, system); turn failed 06:11:14.042Z; server logged Claude Code process exited with code 143 at 06:11:14.044Z.
The 30-minute value coincides with NO_NATIVE_RESUME_IDLE_TIMEOUT_MS, which is why #39547 went down the idle-release path. It is not the idle timeout.
Fix: add unset TMOUT at the top of CLAUDE_GROUP_WATCH_SCRIPT, or strip TMOUT from the spawn environment.