Closing a Terminal Sends Your Coding Agent SIGHUP. How Session Hosts Keep It Alive
Book: System Design Pocket Guide: Interviews The series: Pocket Guides for Developers — 8 short books on agents, RAG, prompts, observability, events, databases and system design — the whole series My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You hand a coding agent a long refactor, watch it start on the test…
When you close a terminal window while a coding agent is executing a long refactor, that process disappears along with any progress it had not saved to disk. The terminal app never actively sought out the agent. Two "hops" caused its demise: the kernel informed the shell that its terminal had disconnected, delivering the SIGHUP signal, and the shell in turn passed that signal to every job it managed.
Different methods can stop this chain of events, each cutting through a distinct hop. "nohup" and "disown" eliminate the job from the shell's list, while "setsid" and "tmux" create a new session, sidestepping the terminal altogether. Only one method, "tmux", leaves the agent with a functional terminal window you can continue interacting with.
To demonstrate, you can test each approach in separate terminal windows. Start a "sleep" command as a background job, then apply each technique and close the window. Use "ps" to monitor which processes remain after the window closes and a new one is opened. The surviving processes show different behaviors depending on the technique employed.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.