PTS(4)

πŸ’– PTS(4) πŸ’–

okay so this is the Kernel Interfaces Manual page for pts, and bestie, it's giving pseudo-terminal driver energy. let's get into it 🫢


✨ NAME ✨

pts β€” pseudo-terminal driver


πŸŽ€ DESCRIPTION πŸŽ€

so the pts driver is literally the support system for a device-pair called a pseudo-terminal. and what IS a pseudo-terminal? it's a pair of character devices: a master device and a slave device. iconic duo behavior πŸ’…

the slave device gives a process an interface that's identical to the one described in tty(4). no cap. but here's the tea: every other device that provides the tty(4) interface has some kind of actual hardware sitting behind it. the slave device? nope. instead, it has another process manipulating it through the master half of the pseudo-terminal. that's the whole vibe.

so like, anything written on the master device gets handed to the slave device as input, and anything written on the slave device gets presented as input on the master device. it's a two-way mirror situation πŸͺžβœ¨


🌸 the ioctl(2) calls that apply ONLY to pseudo-terminals 🌸

these ones are exclusive, they don't do this for just anybody:

  • TIOCPKT β€” turns packet mode on/off. you enable it by specifying (by reference) a nonzero parameter, and disable it by specifying (by reference) a zero parameter. when you apply it to the master side of a pseudo-terminal, every subsequent read(2) from the terminal returns either:
    • data written on the slave part of the pseudo-terminal, preceded by a zero byte (symbolically defined as TIOCPKT_DATA), or
    • a single byte reflecting control status information.

in that second case, the byte is an inclusive-or of zero or more of these bits:

  • TIOCPKT_FLUSHREAD β€” whenever the read queue for the terminal is flushed.
  • TIOCPKT_FLUSHWRITE β€” whenever the write queue for the terminal is flushed.
  • TIOCPKT_STOP β€” whenever output to the terminal is stopped a la '^S'.
  • TIOCPKT_START β€” whenever output to the terminal is restarted.
  • TIOCPKT_DOSTOP β€” whenever VSTOP is '^S' and VSTART is '^Q'.
  • TIOCPKT_NOSTOP β€” whenever the start and stop characters are not '^S/^Q'.

while this mode is in use, the presence of control status information to be read from the master side may be detected by a select(2) for exceptional conditions. πŸ‘€

this mode is used by rlogin(1) and rlogind(8) to implement a remote-echoed, locally '^S/^Q' flow-controlled remote login with proper back-flushing of output. it can be used by other similar programs too, it's not gatekept 🫢

  • TIOCGPTN β€” obtain the device unit number, which can be used to generate the filename of the pseudo-terminal slave device. but wait β€” this ioctl(2) should not be used directly. instead, the ptsname(3) function should be used. okay?? don't be messy 😭
  • TIOCPTMASTER β€” determine whether the file descriptor is pointing to a pseudo-terminal master device. and again, this ioctl(2) should not be used directly β€” it's used to implement routines like grantpt(3). let the library do its thing, bestie πŸ’…

πŸ“ FILES πŸ“

the files used by this pseudo-terminals implementation are:

  • /dev/pts/[num] β€” pseudo-terminal slave devices.

🩺 DIAGNOSTICS 🩺

None.

(yeah. nothing. silence. the healthiest manpage section fr fr 🌈)


πŸ‘€ SEE ALSO πŸ‘€


πŸ“œ HISTORY πŸ“œ

a pseudo-terminal driver appeared in 4.2BSD. then in FreeBSD 8.0, it was replaced with the pts driver. glow-up era βœ¨πŸ‘‘


and that's the whole page, bestie!! this one shipped from Debian, dated August 20, 2008 β€” so like, respect your elders, they've been slaying for a minute πŸ«ΆπŸ’– bye!!

πŸ“¦ where this page comes from