PTY(4)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸŽ€ PTY(4) β€” old-style compatibility pseudo-terminal driver πŸŽ€

okay so this is the PTY(4) page from the Kernel Interfaces Manual, bestie, and it’s literally all about the old-style compatibility pseudo-terminal driver. Think vintage Unix lore, but make it make sense. πŸ’–

🌸 NAME 🌸

pty β€” old-style compatibility pseudo-terminal driver

✨ SYNOPSIS ✨

device pty

πŸ’– DESCRIPTION πŸ’–

The pty driver provides support for the traditional BSD naming scheme that was used for accessing pseudo-terminals before it was replaced by pts(4). This traditional naming is still used in Linux. 🐧✨

When the device /dev/ptyXX is being opened, a new terminal shall be created with the pts(4) driver. A device node for this terminal shall be created, which has the name /dev/ttyXX. No cap, that’s the whole naming situation. πŸŽ€

The pty driver also provides a cloning System V /dev/ptmx device. Iconic behavior, honestly. πŸ’…

🚨 New code should not try to allocate pseudo-terminals using this interface. It is only provided for compatibility with older C libraries that tried to open such devices when posix_openpt(2) was being called, and for running Linux binaries. Like, it’s giving β€œlegacy compatibility only,” not β€œmain character energy.” 😭

πŸ“ FILES πŸ“

The BSD-style compatibility pseudo-terminal driver uses the following device names:

  • /dev/pty[l-sL-S][0-9a-v] β€” Pseudo-terminal master devices.
  • /dev/tty[l-sL-S][0-9a-v] β€” Pseudo-terminal slave devices.
  • /dev/ptmx β€” Control device, returns a file descriptor to a new master pseudo-terminal when opened.

🩺 DIAGNOSTICS 🩺

None. That’s it. No diagnostics listed, bestie. The page is not out here giving us extra lore. 🫢

πŸ‘€ SEE ALSO πŸ‘€

posix_openpt(2), pts(4), tty(4)

πŸ•°οΈ HISTORY πŸ•°οΈ

A pseudo-terminal driver appeared in 4.2BSD. Vintage! πŸ¦‹

πŸ’€ BUGS πŸ’€

Unlike previous implementations, the master and slave device nodes are destroyed when the PTY becomes unused. A call to stat(2) on a nonexistent master device will already cause a new master device node to be created. The master device can only be destroyed by opening and closing it. Lowkey a trap, highkey important. 😭

The pty driver cannot be unloaded, because it cannot determine if it is being used. So yeah β€” it’s staying put, bestie. πŸ’€


Source/version vibes: Debian. Date on the page: October 28, 2019. PTY(4) out β€” slay and goodbye. πŸ’…πŸ«Ά

πŸ“¦ where this page comes from