flush the input and/or output stream
#include <termios.h>
int tcflush( int fildes, int queue_selector );
The tcflush() function flushes the input stream, the output
stream, or both, depending on the value of the argument
queue_selector. At least the following values for
queue_selector are defined in <termios.h>:
- TCIFLUSH
- tcflush() will cause all data
that is received, but not yet read, to be discarded on the
device associated with fildes.
- TCOFLUSH
- tcflush() will cause all data
that is written, but not yet transmitted, to be discarded on
the device associated with fildes.
- TCIOFLUSH
- tcflush() will cause all data
that is written, but not yet transmitted, as well as all
data that is received, but not yet read, to be discarded on
the device associated with fildes.
- 0
- Success
- -1
- An error occurred. errno is set to indicate the error.
- EBADF
- The argument fildes is invalid.
- EINVAL
- The argument queue_selector is invalid.
- ENOSYS
- The resource manager associated with fildes doesn't support
this call.
- ENOTTY
- The argument fildes doesn't refer to a terminal device.
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
void main()
{
int fildes;
fildes = open( "/dev/ser1", O_RDWR );
/*
* Throw away all input data
*/
tcflush( fildes, TCIFLUSH );
close( fildes );
}
POSIX 1003.1
Safety: | |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno,
tcdrain(),
tcflow(),
tcsendbreak()