tty_ldisc_ref_wait(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ tty_ldisc_ref_wait ✨

okay so bestie, welcome to the kernel API manual for tty_ldisc_ref_wait β€” yes it's giving obscure-subsystem energy but honestly it's kind of iconic once you get it πŸŽ€


🌸 SYNOPSIS 🌸

struct tty_ldisc * tty_ldisc_ref_wait (struct tty_struct *tty );

πŸ’– ARGUMENTS πŸ’–

  • tty β€” the tty device, bestie. that's the one. the terminal in question πŸ–₯️✨

πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does is: it dereferences the line discipline for the terminal and takes a reference to it. That's the whole vibe. πŸ’…

And if the line discipline is in flux β€” like, mid-change, going through it, having a moment β€” then it just waits patiently until it changes. no cap. it literally waits. 🫢

⚠️ Note 1

Must not be called from an IRQ/timer context. periodt. πŸ™…β€β™€οΈ

The caller also has to be careful not to hold other locks that will deadlock against a discipline change β€” like, for example, an existing ldisc reference (which, fun fact, we check for πŸ‘€).

πŸ’€ Note 2

A file_operations routine (read/poll/write) should use this function to wait for any ldisc lifetime events to finish. like it's literally the designated waiter for that job πŸ“


πŸ”₯ RETURN πŸ”₯

  • NULL β€” if the tty has been hungup and not re-opened with a new file descriptor 😭
  • otherwise β€” a valid ldisc reference πŸ‘‘βœ¨

🌈 SEE ALSO 🌈

Kernel file ./drivers/tty/tty_ldisc.c, plus the whole friend group:


and that's the page, babe πŸ’œ this iconic little number lives in ./drivers/tty, dated October 2026, and it's part of the Kernel API Manual β€” go forth and reference your line disciplines responsibly, mwah πŸ§šβ€β™€οΈπŸ’‹

πŸ“¦ where this page comes from