TTY
TTY is the Unix abstraction for a terminal device, inherited from teletypewriters. It defines stdin, stdout, signals, and line discipline for every CLI.
TTY is short for "teletypewriter," the electromechanical devices that were the original user interface to timesharing Unix systems in the 1970s. The name stuck as the abstraction for any character-oriented terminal device the kernel exposes. Today a TTY is usually not a physical machine but a virtual one — either a kernel virtual console (/dev/tty1) or a PTY pair backing a terminal emulator.
Why it matters
The TTY abstraction is what makes CLIs feel the way they do. Line editing, echo, Ctrl+C sending SIGINT, Ctrl+D sending EOF, window resize signals, foreground/background process groups, the distinction between stdout and stderr — all of this is TTY behavior baked into the kernel's line discipline. If you strip the TTY away (by piping to a file), programs drop the interactive features and often switch output format.
For AI-first developer tools like SpaceSpider, this matters because Claude Code, Codex CLI, and Qwen Code all rely on TTY semantics for streaming output, interactive confirmation prompts, and ANSI escape code rendering. Every pane in a SpaceSpider grid layout is a real TTY so these tools behave identically to running them in a native terminal.
How it works
Under the hood, a TTY device file is a kernel endpoint with an associated termios structure. termios holds dozens of flags controlling input canonicalization, output post-processing, control characters (like the current interrupt key), and baud rate (a legacy from actual serial lines). User-space talks to the kernel via tcgetattr/tcsetattr to toggle raw mode, ioctl(TIOCGWINSZ) to read the current size in rows and columns, and standard read/write for data.
The kernel also tracks the TTY's foreground process group, which is the set of processes that receive signals from Ctrl+C, Ctrl+Z, and related keys. This is how a running vim can catch Ctrl+C while a background job doesn't.
isatty(fd) returns true when a file descriptor is connected to a TTY. CLI tools branch on this to decide colorization, paging, and prompt style.
Related terms
- PTY — the pseudo-terminal that emulates a TTY in software
- ConPTY — the Windows equivalent
- Shell — the TTY's most common client
- ANSI escape codes — the control language spoken over a TTY
- Terminal multiplexer — tools that multiplex many TTYs
FAQ
What's the difference between a TTY and a PTY?
A TTY is the abstract kernel device; a PTY is a specific flavor of TTY implemented as a master/subordinate pair in software. Every PTY is a TTY, but not every TTY is a PTY (kernel consoles, serial lines, and SSH sessions are also TTYs).
How do I check what TTY a process is attached to?
Run tty inside a shell, or look at ps -o tty for any process. Background daemons show ? because they have no controlling TTY.
Related terms
- Agentic codingAgentic coding is software development where an LLM-powered agent plans, edits, runs, and verifies code on its own using tools, not just autocomplete.
- AI pair programmingAI pair programming is a collaboration style where an LLM assistant sits alongside you, suggesting code and reviewing changes in real time as you work.
- ANSI escape codesANSI escape codes are control sequences that terminals interpret for colors, cursor movement, and screen clearing — the language of every modern CLI UI.
- Autonomous agentAn autonomous agent is an AI program that perceives, decides, and acts on its own toward a goal — the architecture behind modern coding CLIs.
- CheckpointA checkpoint is a saved snapshot of file state that lets you roll back an AI coding agent's changes to a known-good point.
- Claude CodeClaude Code is Anthropic's official command-line agent that plans, edits, runs, and verifies code across your repo using Claude models and tool use.