tcdrain(3)

πŸ’– tcdrain β€” bestie's guide to waiting for your output to actually leave πŸ’–

okay so real talk, this is tcdrain(3) from the Library Functions Manual, and it is genuinely one of the most patient little functions in the whole termios friend group. it's giving "wait for me!!" energy and honestly? iconic. 🫢


✨ NAME ✨

tcdrain β€” block until output is transmitted

like, that's the whole vibe. it blocks. it waits. it does not leave until the output is out. periodt. πŸ’…


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

so yeah, you gotta link it, bestie, no cap. add that -lc and go. ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <termios.h>

int tcdrain(int fd);

she's small. she's simple. she takes exactly one friend. 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the tea: tcdrain() waits until all output written to the object referred to by fd has been transmitted. 🧚

that's it. that's the whole function. it doesn't flush, it doesn't discard, it doesn't negotiate β€” it just sits there like the world's most loyal bestie holding your hand until every last byte you wrote to fd has actually made it out the door. all of it. not some of it. all of it. πŸ’―


πŸ”₯ RETURN VALUE πŸ”₯

  • 0 β€” on success. slay, your bytes are gone, you're free. πŸŽ‰
  • -1 β€” on failure, and it sets errno to indicate the error. yeah, it texted you back with the reason, check errno. 😭

πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, see attributes(7) β€” go read it, iykyk.

  • tcdrain() β€” Thread safety: MT-Safe βœ…

that's a win, bestie. MT-Safe means you can call her from multiple threads and she will not start drama. 🌈


⭐ STANDARDS ⭐

POSIX.1-2008. certified, blessed, standardized. the queen has paperwork. πŸ‘‘


πŸ’€ HISTORY πŸ’€

POSIX.1-2001. she's been here since forever, lowkey a legend from the very start of the POSIX era. 🌸


πŸ’œ SEE ALSO πŸ’œ

her besties, fr fr:

go say hi to all of them, they're all part of the same terminal-lineage group chat. 🫢


lowkey reminder: tcdrain() blocks. as in, your thread is gonna stand there in line waiting until the hardware/pipe/whatever is fully done transmitting. don't call her on your main character thread unless you're ready for the wait. 😭

mwah πŸ’‹ that's the whole page, bestie. this one lives in Linux man-pages 6.20, dated 2026-07-02 β€” so if you're reading an older or newer copy, check the date before you come for me. ily, go write some bytes and wait for them properly. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ 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