tcflush(3)

πŸ’– tcflush β€” bestie edition πŸ’–

okay so this one is a page from the Library Functions Manual, and it's called tcflush(3). yes the (3) is part of the name, that's just how library-call girlies do it πŸŽ€ it lives in the Standard C library, a.k.a. libc, a.k.a. -lc when you're linking. iconic. periodt.


✨ NAME ✨

tcflush β€” discard pending data πŸ’…

like. it throws away the leftovers. the un-sent, the un-read. ghosting your terminal data fr fr.


🫢 LIBRARY 🫢

Standard C library (libc, -lc)


🌸 SYNOPSIS 🌸

#include <termios.h>

int tcflush(int fd, int queue_selector);

two args, one int for the file descriptor, one int for the queue selector. simple. clean. lowkey elegant.


πŸ’œ DESCRIPTION πŸ’œ

so tcflush() discards data. and which data it discards depends entirely on queue_selector, okay bestie, pay attention:

  • it'll toss data written to the object that fd refers to but that hasn't actually been transmitted yet, or
  • it'll toss data that's been received but hasn't been read yet.

and the queue_selector values are:

  • TCIFLUSH β€” flushes data received but not read. bye bestie πŸ‘‹
  • TCOFLUSH β€” flushes data written but not transmitted. never made it out the door πŸ’€
  • TCIOFLUSH β€” flushes BOTH of them: data received but not read, AND data written but not transmitted. equal opportunity deletion. slay.

⭐ RETURN VALUE ⭐

  • 0 β€” on success πŸŽ‰ everything's fine, nothing to worry about, go off
  • -1 β€” on failure, and it sets errno to indicate the error 😭 check your errno, that's the whole point

πŸ¦‹ ATTRIBUTES πŸ¦‹

for an explanation of the terms used in this section, go peek at attributes(7) β€” it's giving homework but it's worth it.

  • interface: tcflush()
    • attribute: Thread safety
    • value: MT-Safe ✨ (yes bestie, you can call it from multiple threads, it's safe, we love that for us)

πŸŽ€ STANDARDS πŸŽ€

POSIX.1-2008. that's the one. πŸ‘‘


🌈 HISTORY 🌈

POSIX.1-2001. so it's been around a while β€” vintage, but make it fashion πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


just a lil reminder bestie: flushing means the data is gone. discarded. not queued, not saved, not buffered somewhere cute. if you weren't done with it, that's on you πŸ™ˆ

and that's the whole page!! this one came from Linux man-pages 6.20, dated 2026-07-02 β€” shoutout to the man-pages girlies for keeping the docs fed 🫢 mwah, go flush responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: GPL-2.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms