TCFLUSH(3P)

πŸ’… TCFLUSH(3P) β€” bestie's guide to flushing terminal queues

okay so this one is from the POSIX Programmer's Manual, section 3P, and the name is literally tcflush. welcome to the group chat πŸ’–


✨ PROLOG

so like, real talk first: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the actual Linux tea β˜•), or honestly the interface may not be implemented on Linux at all. not me warning you before we even start πŸ™ˆ


🌸 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 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) but not transmitted, or data received but not read β€” and which one it does 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 ✨

and now the dramatic 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. 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. slay, no cap πŸ‘‘


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


πŸ”₯ ERRORS

the tcflush() function shall fail if:

  • EBADF β€” the fildes argument is not a valid file descriptor. fake fd, we don't know her πŸ’€
  • EINVAL β€” the queue_selector argument is not a supported value. not a real selector bestie 😭
  • EIO β€” the process group of the writing process is orphaned, the calling thread is not blocking SIGTTOU, and the process is not ignoring SIGTTOU. the way that's three whole conditions πŸ’€
  • ENOTTY β€” the file associated with fildes is not a terminal. sorry, this is giving "not a tty" energy 🫠

the following sections are informative (iykyk, that means they're ✨vibes only✨, not actual requirements):


🌈 EXAMPLES

None. nothing. zero. nada. the void πŸ•³οΈ


πŸ’œ APPLICATION USAGE

None. again, nothing. iconic of them honestly.


⭐ RATIONALE

None. truly no thoughts, head empty 🧠✨


🌸 FUTURE DIRECTIONS

None. the future is... also nothing. periodt.


🧚 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. 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 (so like, if they fight, the original wins πŸ₯Š). 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 .


so yeah, that's the whole page. no notes, only facts, and every single one of them stayed πŸ’–

kisses, and this page was brought to you by IEEE/The Open Group, 2017 β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from