tty_set_ldisc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ tty_set_ldisc(9) πŸ’œ

okay bestie, welcome to the Kernel API Manual β€” we're doing tty_set_ldisc(9) today and honestly it's giving "small function, big responsibilities" ✨


🌸 NAME 🌸

tty_set_ldisc β€” set line discipline

like, literally just: set the line discipline. that's the whole gig. πŸŽ€


✨ SYNOPSIS ✨

int tty_set_ldisc (struct tty_struct *tty , int disc );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • tty β€” the terminal you're setting. the main character terminal, if you will πŸ‘‘
  • disc β€” the line discipline number. the vibe you're assigning to it πŸ’…

πŸ”₯ DESCRIPTION πŸ”₯

so the whole point: you're setting the discipline of a tty line. that's it, that's the function. 🫢

⚠️ real talk though: it must be called from a process context. no cap. don't try to be cute and call it from somewhere else, that's not the move 😭

ngl the ldisc change logic has to be kind of paranoid, and for good reason β€” it has to protect itself against:

  • any overlapping ldisc change (including a change happening on the other end of pty pairs πŸ‘€ the way that pty pair is also living its own life)
  • the close of one side of a tty/pty pair πŸ’€
  • and eventually hangup πŸ™ˆ

so yeah, it's guarding against a whole group chat of race conditions. slay that it handles it, but don't make its life harder. periodt.


🌈 SEE ALSO 🌈

Kernel file ./drivers/tty/tty_ldisc.c β€” and the whole ldisc friend group, which is honestly iconic 🧚:


πŸ“ ok that's the whole page bestie, go forth and set those disciplines responsibly πŸ’–

from the ./drivers/tty directory, dated October 2026, this has been tty_set_ldisc(9) β€” mwah, ily, bye πŸ’…βœ¨

πŸ“¦ where this page comes from