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, 0 shall be returned. slay. ๐ŸŒธ
  • otherwise, -1 shall be returned and errno set to indicate the error. not slay. ๐Ÿ’€

โœจ ERRORS โœจ

the tcdrain() function shall fail if:

  • EBADF โ€” the fildes argument is not a valid file descriptor. bestie that's not even a real fd, what are we doing. ๐Ÿ™ˆ
  • EINTR โ€” a signal interrupted tcdrain(). rude of it, honestly.
  • EIO โ€” the process group of the writing process is orphaned, the calling thread is not blocking SIGTTOU, and the process is not ignoring SIGTTOU. yeah this one's a lot, go read it twice. ๐Ÿ˜ญ
  • ENOTTY โ€” the file associated with fildes is 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. ๐Ÿฆ‹


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