tty_port_close_start(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– tty_port_close_start(9) πŸ’–

okay bestie, so this is a page from the Kernel API Manual and it's basically the part one of a two-part glow-up for closing a tty port. the way that kernel drivers need a whole two-step routine for "goodbye"... iconic honestly πŸŽ€


🌸 NAME 🌸

tty_port_close_start β€” the helper for tty->ops->close, part 1/2 ✨ (yes, there's a part two, we'll get there)


πŸ¦‹ SYNOPSIS πŸ¦‹

int tty_port_close_start (struct tty_port *port , struct tty_struct *tty
, struct file *filp );

πŸŽ€ ARGUMENTS πŸŽ€

  • port β€” the tty_port of the device, aka the whole vibe of the port itself πŸ’…
  • tty β€” the tty that's being closed, the main character of this moment 😭
  • filp β€” the file pointer that got passed on through, no cap

✨ DESCRIPTION ✨

okay so here's the tea: this function decrements and checks the open count. lowkey the bouncer at the door checking how many people are still inside 🫢

and if this happens to be the last close? it flushes the port. which means β€” and this is the important part, bestie β€” it drops the data from the output buffer on the device and waits for the sending logic to finish. literally "no more messages in the group chat, let everyone finish typing first" energy πŸ’€

the rest of the close handling? that's not here. that's tty_port_close_end's job. part 2. the sequel. we love a franchise πŸ”₯

Locking note, do not skip this one: the caller holds the tty lock. not optional, not vibes-based, the caller already has it before calling. πŸ”’

🌈 RETURN 🌈

  • 1 β€” this is the last close πŸŽ‰ (everyone's gone, turn off the lights)
  • 0 β€” nope, not the last close, other openers are still here πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./drivers/tty/tty_port.c, plus the whole friend group:


and that's the whole page babes πŸ’œ go read tty_port_close_end(9) next, she's the other half of this story.

source/location: ./drivers/tty β€” dated October 2026 β€” mwah, love u, bye! πŸ“βœ¨

πŸ“¦ where this page comes from