tty_ldisc_ref_wait(9)
β¨ 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:
tty_register_ldisc(9)tty_unregister_ldisc(9)tty_ldisc_get(9)tty_ldisc_put(9)tty_ldisc_ref(9)tty_ldisc_deref(9)tty_ldisc_flush(9)tty_set_termios_ldisc(9)tty_ldisc_open(9)tty_ldisc_close(9)tty_ldisc_failto(9)tty_ldisc_restore(9)tty_set_ldisc(9)tty_ldisc_kill(9)tty_reset_termios(9)tty_ldisc_reinit(9)tty_ldisc_hangup(9)tty_ldisc_setup(9)tty_ldisc_release(9)tty_ldisc_init(9)tty_ldisc_deinit(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms