tty_port_tty_get(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… tty_port_tty_get(9) β€” a Kernel API Manual moment

okay bestie, welcome to the Kernel API Manual, section 9, and the star of the show is tty_port_tty_get πŸŽ€ lowkey one of the most useful little functions in the tty world and I need you to know about it.


✨ NAME ✨

tty_port_tty_get β€” get a tty reference 🫢 like literally just grab one, safely.


🌸 SYNOPSIS 🌸

struct tty_struct * tty_port_tty_get (struct tty_port *port );

that's it. that's the whole vibe. one function, one pointer in, one pointer out πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • port β€” the tty port, bestie. that's the thing you're passing in. the port itself. 🐚

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea β˜• β€” this function returns a refcount protected tty instance. meaning it hands you a tty and it's already got its refcount situation handled for you, no cap. responsible queen behavior πŸ‘‘

and if the port is not associated with a tty? you get NULL. that happens, like, when the port has been closed or hung up (eg due to close or hangup). so yes, NULL is a real possible answer and you should be checking for it, ngl πŸ™ˆ

fr fr β€” don't just assume you're getting a tty back. check your return value, it's giving basic safety and it's iconic πŸ’…

🌈 SEE ALSO 🌈

the kernel file lives at ./drivers/tty/tty_port.c and here's the whole friend group, all 24 of them, in the exact order they were introduced to me 🧚:


mwah πŸ’‹ that's the page. go get your refcount-protected tty and slay.

sign-off time πŸŽ€ β€” this one comes from ./drivers/tty, dated October 2026, and it's page tty_port_tty_get(9). periodt. πŸ’œ

πŸ“¦ where this page comes from