TCFLUSH(3POSIX)

πŸ’– PROLOG πŸ’–

okay so before we even get into it: this page is part of the POSIX Programmer's Manual, bestie. that's the whole vibe. and a heads-up fr fr β€” the Linux implementation of this interface may differ, so go check the corresponding Linux manual page for the deets on Linux behavior. or honestly? the interface might not even be implemented on Linux. πŸ™ˆ just so you know.


✨ NAME ✨

tcflush β€” flush non-transmitted output data, non-read input data, or both πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <termios.h>

int tcflush(int fildes, int queue_selector);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, upon successful completion, tcflush() shall discard data written to the object referred to by fildes (that's an open file descriptor associated with a terminal, iykyk) but not transmitted, or data received but not read β€” it depends on the value of queue_selector:

  • if queue_selector is TCIFLUSH, it shall flush data received but not read. πŸ“₯
  • if queue_selector is TCOFLUSH, it shall flush data written but not transmitted. πŸ“€
  • if queue_selector is TCIOFLUSH, it shall flush both data received but not read and data written but not transmitted. πŸ”„

now the spicy part 🌢️ β€” attempts to use tcflush() 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. that's giving main character energy but in a "you got caught" way 😭.

but β€” if the calling thread is blocking SIGTTOU signals, or the process is ignoring SIGTTOU signals, then the process shall be allowed to perform the operation, and no signal is sent. slay, loophole. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

upon successful completion, 0 shall be returned. otherwise, -1 shall be returned and errno set to indicate the error. that's it, that's the deal. ⭐


πŸ’€ ERRORS πŸ’€

the tcflush() function shall fail if:

  • EBADF β€” the fildes argument is not a valid file descriptor. πŸ‘»
  • EINVAL β€” the queue_selector argument is not a supported value. 🚫
  • EIO β€” the process group of the writing process is orphaned, the calling thread is not blocking SIGTTOU, and the process is not ignoring SIGTTOU. 😭
  • ENOTTY β€” the file associated with fildes is not a terminal. πŸ™ˆ
also: the following sections are informative. not binding, just vibes. 🌈

πŸ“ EXAMPLES πŸ“

None.


🧚 APPLICATION USAGE 🧚

None.


πŸ’œ RATIONALE πŸ’œ

None.


🌸 FUTURE DIRECTIONS 🌸

None.


πŸ‘‘ SEE ALSO πŸ‘‘

  • tcdrain()
  • The Base Definitions volume of POSIX.1‐2017, Chapter 11, General Terminal Interface, <termios.h>

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. πŸ’–

and listen β€” 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. no cap, that's the authority. 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 .


and that's the whole page, bestie 🫢 β€” brought to you by IEEE/The Open Group, 2017, under the name TCFLUSH(3POSIX) in the POSIX Programmer's Manual. periodt. ✨