The TTY Demystified (2008)

· ai systems · Source ↗

TLDR

  • Classic deep-dive into Linux TTY subsystem: history from 1869 teletypes through UARTs, line disciplines, PTYs, and job control signals.

Key Takeaways

  • The TTY subsystem layers UART driver, line discipline (N_TTY), and TTY driver together; each is a passive object invoked by process or interrupt context.
  • Line discipline sits between UART and application, providing cooked/raw mode, edit buffer, echo, and linefeed conversion before bytes reach userspace.
  • Session management and job control (foreground process group, SIGTSTP, SIGHUP) are handled by the TTY driver cooperating with the shell as session leader.
  • Pseudo terminals (PTYs) move terminal emulation to userland while keeping TTY session management intact; xterm, ssh, and screen all stack PTYs.
  • The kernel communicates asynchronously with processes via signals, not ioctl, making TTY signal handling notoriously complex.

Hacker News Comment Review

  • No substantive HN discussion yet; single comment notes the page is a long-standing reference that resurfaces periodically as a recommended deep read.

Original | Discuss on HN