tty_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ tty_release(9) πŸŽ€

okay bestie come CLOSE-r, we're looking at a page from the Kernel API Manual and it's lowkey iconic πŸ’…


✨ NAME ✨

tty_release β€” the vfs callback for close, periodt 🫢


🌸 SYNOPSIS 🌸

int tty_release (struct inode *inode , struct file *filp );

like, that's the whole signature, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” the inode of the tty πŸ’–
  • filp β€” the file pointer for the handle to the tty πŸŽ€

πŸ’œ DESCRIPTION πŸ’œ

So this one gets called the last time each file handle is closed that references this tty β€” but bestie, heads up: there may however be several such references πŸ‘€ like it's not necessarily the very last one ever, iykyk.

Locking: it takes BKL. see tty_release_dev. πŸ”₯

ngl, even releasing the tty structures is a tricky business 😭 we have to be very careful that the structures are all released at the same time, because interrupts might otherwise get the wrong pointers. like genuinely, that's the vibe check that matters here πŸ’€

WSH 09/09/97: rewritten to avoid some nasty race conditions that could lead to double frees or releasing memory still in use. not me fixing double frees in '97, king behaviour πŸ‘‘

🌈 SEE ALSO 🌈

Kernel file ./drivers/tty/tty_io.c β€” and then the whole extended friend group 🫢:


and that's the page, bestie πŸ’– this lil gem lives in ./drivers/tty and it's dated October 2026 β€” mwah, slay, go close some file handles responsibly πŸ§šβ€β™€οΈπŸ’…

πŸ“¦ where this page comes from