PTY
A PTY is a virtual terminal pair that lets programs talk to each other as if through a physical serial terminal, enabling real shells inside apps.
A PTY (pseudo-terminal) is a pair of virtual character devices — a master and a subordinate — that behave like a real hardware terminal. One process writes to the master, and the other reads from the subordinate as if it were a serial line. This is how xterm, tmux, SSH, and every modern terminal emulator run shells and programs with full TTY semantics.
Why it matters
Most command-line tools check isatty() and change behavior when they think they're connected to a terminal: ls shows colors, git log opens a pager, and AI CLIs like Claude Code stream interactive prompts instead of dumping batched output. Without a PTY, these programs act as if piped to a file — no colors, no interactivity, no line editing.
SpaceSpider spawns one PTY per pane so every CLI you run — claude, codex, qwen, kimi, or your login shell — sees a real terminal and runs in its normal interactive mode. See first-space for how panes map to PTY sessions.
How it works
On Linux and macOS, the kernel provides /dev/ptmx and /dev/pts/N. Calling posix_openpt() allocates a new master/subordinate pair. The master is used by the terminal emulator or host application to send keystrokes and receive output; the subordinate is what the child process inherits as its stdin, stdout, and stderr.
The kernel's line discipline sits between the two ends, handling features like line buffering, echo, backspace editing, and signal generation (Ctrl+C becomes SIGINT). Terminal size is tracked via TIOCSWINSZ ioctls; resizing the host sends SIGWINCH to the child.
On Windows the equivalent is ConPTY, which exposes similar semantics via CreatePseudoConsole. Cross-platform libraries like portable-pty (Rust) and node-pty (Node.js) abstract both.
How it's used
Any application that embeds a terminal — IDEs like VS Code, tools like tmux and Zellij, SSH servers, and terminal multiplexers — uses PTYs. SpaceSpider is no exception: each pane in a grid layout is a PTY bridged to @xterm/xterm in the browser-style renderer.
Related terms
- TTY — the underlying teletypewriter abstraction
- ConPTY — the Windows equivalent
- ANSI escape codes — the control sequences carried over a PTY
- Shell — the program most commonly hosted in a PTY
- Terminal multiplexer — tools that manage many PTYs
FAQ
Why not just use pipes?
Pipes lack line discipline, window size, signals, and the isatty() property. Programs detect this and disable interactive features. A PTY preserves the full terminal contract.
Can I see all open PTYs on my system?
On Linux, ls /dev/pts lists subordinate devices. Each open terminal window, tmux pane, or SSH session typically owns one. SpaceSpider's pane count equals the number of PTYs it holds open.
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.