PTY(4)
π PTY(4) π
okay bestie, gather round β this is the manual page for pty, section 4 of the Kernel Interfaces Manual. it's giving "vintage but still showing up to the party" energy. let's get into it π«Ά
β¨ NAME β¨
pty β the old-style compatibility pseudo-terminal driver. yes, compatibility, as in "we keep it around for the elders." iconic behavior honestly.
πΈ SYNOPSIS πΈ
device pty
that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
so the pty driver is basically the nostalgia corner of pseudo-terminals. it supports the traditional BSD naming scheme that everybody used for accessing pseudo-terminals before pts(4) came in and took over. and like β that traditional naming is still what Linux uses, so it never fully left the group chat. no cap.
here's the tea: when the device /dev/ptyXX gets opened, a new terminal shall be created using the pts(4) driver. and then a device node for that terminal gets created too, named /dev/ttyXX. β¨ automatic. no notes.
the pty driver also hands you a cloning System V /dev/ptmx device, because it's generous like that.
π¨ real talk bestie: new code should NOT try to allocate pseudo-terminals using this interface. it's only here for compatibility with older C libraries that tried to open such devices when posix_openpt(2) was being called, and for running Linux binaries. that's it. that's the whole job. periodt.
π FILES π
the BSD-style compatibility pseudo-terminal driver uses these device names, and you're gonna want to write them down fr fr:
/dev/pty[l-sL-S][0-9a-v]β the pseudo-terminal master devices π/dev/tty[l-sL-S][0-9a-v]β the pseudo-terminal slave devices βοΈ/dev/ptmxβ the control device; when you open it, it returns a file descriptor to a new master pseudo-terminal π
π DIAGNOSTICS π
None.
that's the whole section. not a single diagnostic. she said "no thoughts, head empty, no errors." π
π₯ SEE ALSO π₯
go read these next, i'm obsessed:
β HISTORY β
a pseudo-terminal driver appeared in 4.2BSD. ancient. legendary. foundational. we love a pioneer π
π BUGS π
okay so this is the messy part, and you need to hear it:
- unlike previous implementations, the master and slave device nodes are destroyed when the PTY becomes unused. so they justβ¦ vanish. gone. ghosted. π
- a call to
stat(2)on a nonexistent master device will already cause a new master device node to be created. yes, just checking on it resurrects it. main character energy tbh. - the master device can only be destroyed by opening and closing it. that's the only way out. π
- the
ptydriver cannot be unloaded, because it cannot determine if it is being used. it literally doesn't know if anyone's home, so it justβ¦ stays. forever. we stan a committed queen π
mwah π that's the whole page! this one came from the Debian crew, dated October 28, 2019. take care of her, she's vintage πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms