TCDRAIN(3P)
๐ซถ TCDRAIN โ wait for transmission of output
okay bestie, so this one is from the POSIX Programmer's Manual, and before we even get into it: ๐ this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior, fr), or honestly the interface may just not be implemented on Linux at all. vibe check before you commit, yk?
โจ NAME โจ
tcdrain โ wait for transmission of output. it's giving patience. it's giving "hold on, let me finish talking." ๐
โจ SYNOPSIS โจ
#include <termios.h>
int tcdrain(int fildes);
โจ DESCRIPTION โจ
so the tcdrain() function shall block until all output written to the object referred to by fildes is transmitted. literally just sitting there, waiting, like a bestie holding your bag while you finish your story. ๐
the fildes argument is an open file descriptor associated with a terminal.
and here's the dramatic part ๐ โ any attempts to use tcdrain() from a process which is a member of a background process group on a fildes associated with its controlling terminal, shall cause the process group to be sent a SIGTTOU signal. yes, a whole signal, sent to the whole group, for trying it. ๐ญ
BUT โ if the calling thread is blocking SIGTTOU signals or the process is ignoring SIGTTOU signals, the process shall be allowed to perform the operation, and no signal is sent. so like, if you've already got your noise-cancelling headphones on, the universe lets you cook. โจ
โจ RETURN VALUE โจ
- upon successful completion,
0shall be returned. slay. ๐ธ - otherwise,
-1shall be returned anderrnoset to indicate the error. not slay. ๐
โจ ERRORS โจ
the tcdrain() function shall fail if:
EBADFโ thefildesargument is not a valid file descriptor. bestie that's not even a real fd, what are we doing. ๐EINTRโ a signal interruptedtcdrain(). rude of it, honestly.EIOโ the process group of the writing process is orphaned, the calling thread is not blockingSIGTTOU, and the process is not ignoringSIGTTOU. yeah this one's a lot, go read it twice. ๐ญENOTTYโ the file associated withfildesis not a terminal. it's giving "you brought a toaster to a terminal party." ๐
the following sections are informative. (translation: the tea is optional, but we're still serving it. ๐)
โจ EXAMPLES โจ
None. ๐ no examples, no crumbs, we starve.
โจ APPLICATION USAGE โจ
None. ๐ง again, nothing. the void said "no comment."
โจ RATIONALE โจ
None. ๐ iconic of it to have zero reasoning and full confidence.
โจ FUTURE DIRECTIONS โจ
None. ๐ฎ we do not know the future and neither does POSIX.
โจ SEE ALSO โจ
tcflush()- the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface,
<termios.h>
iykyk, go read those next. ๐ฆ
โจ COPYRIGHT โจ
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . ๐ซถ
okay that's the whole page, bestie โ every flag, every error, every word, we kept it all, no cap. this one came to you from IEEE/The Open Group, 2017, and the manual is TCDRAIN(3P). go wait for your output to finish transmitting, you main character. ๐
๐๐
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms