Agent view restarts the background daemon during system shutdown; the new daemon holds the shutdown for 90 s
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?
On Linux the background daemon runs inside the cgroup of the client that started it. Here that's the Ghostty surface scope of the terminal running claude agents. At a reboot, systemd sends SIGTERM to every process in that scope. The daemon exits, and 262 ms later daemon.log records a new daemon starting in the same scope. The agent view started it, having received the same SIGTERM and being in the middle of its own exit. The new daemon adopts the remaining worker and spawns a warm spare. The new daemon, the spare and the spare's MCP servers were all started after systemd sent SIGTERM, so systemd waits out the scope's 90 s stop timeout and then SIGKILLs them. The console shows A stop job is running for User Manager for UID 1000 (…/ 2min) for the whole wait.
The agent view's debug log shows a terminal write failing with EIO at 02:11:53.022, and its attach returning 5 ms later. The session list remounts, the list starts a warm spare (7917051b), and the spare's dispatch finds no daemon (ENOCONN, .128). 86 ms later the new daemon's own debug log begins, and daemon.log records its start at .265. In 2.1.289 the dispatch code answers an ENOCONN by retrying once through the path that starts a daemon, which runs claude daemon run --origin transient. I couldn't find a check on that path for the client's own shutdown. When the daemon shuts down, on SIGTERM as for any other cause, it destroys its client connections without writing anything to them, so on the socket a shutdown looks the same as a crash.
What Should Happen?
A reboot isn't held up by Claude Code: a client that is itself exiting doesn't start a daemon, so nothing new is left in the terminal's scope after systemd's SIGTERM.
Error Messages/Logs
~/.claude/daemon.log (excerpt):
[2026-10-04T02:11:53.003Z] [supervisor] shutting down (cause=signal, uptime=11204s, leases=2, live_workers=1)
[2026-10-04T02:11:53.265Z] [supervisor] ─── daemon start ─── version=2.1.289 pid=384816 origin=transient
[2026-10-04T02:11:53.279Z] [bg] bg adopt: adopted=1 respawned=0 dead=0
[2026-10-04T02:11:53.281Z] [bg] bg orphan-spare reap: 1
[2026-10-04T02:11:53.294Z] [bg] bg spare spawned host pid=384854
The agent view's debug log (~/.claude/debug/<id>.txt), same reboot (excerpt):
2026-10-04T02:11:53.022Z [DEBUG] nonBlockingStdout: uninstalling (Error: EIO: i/o error, write)
2026-10-04T02:11:53.027Z [DEBUG] [PERF:bg-attach-end]
2026-10-04T02:11:53.028Z [DEBUG] [FV-attach] attachJob returned after 11201205ms — remounting list
2026-10-04T02:11:53.031Z [DEBUG] [PERF:bg-remount-start]
2026-10-04T02:11:53.081Z [DEBUG] [PERF:bg-remount-end]
2026-10-04T02:11:53.081Z [DEBUG] [PERF:bg-spare-start] 7917051b
2026-10-04T02:11:53.121Z [WARN] deleteJob: kill unconfirmed for acbb4ef2 — skipping jobdir/worktree removal to avoid stranding a live worker
2026-10-04T02:11:53.128Z [DEBUG] bg: socket dispatch fell through (ENOCONN), using file path
2026-10-04T02:11:53.191Z [ERROR] restoreTerminalModes write failed: Error: EIO: i/o error, write
journal (excerpt):
02:11:52.948332 systemd-logind[986]: reboot requested from client PID 384498 ('systemctl') …
02:11:53.002756 systemd[1211]: Stopping app-ghostty-surface-transient-4623.scope...
02:13:23.147107 systemd[1211]: app-ghostty-surface-transient-4623.scope: Stopping timed out. Killing.
02:13:23.147485 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384816 (claude) with signal SIGKILL.
02:13:23.147638 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384854 (2.1.289) with signal SIGKILL.
02:13:23.147746 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384861 (2.1.289) with signal SIGKILL.
02:13:23.147865 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384924 (2.1.289) with signal SIGKILL.
02:13:23.148002 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384932 (2.1.289) with signal SIGKILL.
02:13:23.148180 systemd[1211]: app-ghostty-surface-transient-4623.scope: Killing process 384974 ([redacted MCP server name]) with signal SIGKILL.
02:13:23.177282 systemd[1211]: app-ghostty-surface-transient-4623.scope: Failed with result 'timeout'.
Every PID killed is higher than the PID of the systemctl reboot that began the shutdown. The last one is an MCP server the spare started (name redacted).
Steps to Reproduce
Seen once; these are the conditions it happened under, not yet re-run:
- On Arch with a systemd 262 user session and Ghostty (one scope per terminal surface), with no daemon running, open a terminal and run
claude agents, so the daemon starts in that terminal's scope. - Attach to a background session from the agent view.
- Reboot while still attached.
The reboot waited 90 s on that terminal's scope. daemon.log showed shutting down (cause=signal …) followed 262 ms later by daemon start … origin=transient. The journal showed the scope's Stopping timed out. Killing. naming the new daemon and its spare.
For comparison: the two reboots that followed had no daemon running, and their stop phase took 2.7 s and 2.6 s. Since 2026-08-26, as far back as my journal goes, daemon.log has seven earlier system shutdowns where the daemon was signalled with leases=0 (no claude agents or other client connected). None was followed by a daemon start, and the user manager stopped in 5.9–7.6 s each time.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.289 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
Arch Linux, kernel 7.2.8-zen, systemd 262, Ghostty 1.3.1. Ghostty gives each terminal surface its own app-ghostty-surface-transient-<pid>.scope. Native install.