[Previous] [Contents] [Index] [Next]

tcflush()

Flush the input and/or output stream

Synopsis:

#include <termios.h>

int tcflush( int fildes, 
             int queue_selector );

Library:

libc

Description:

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
Discard all data that's received, but not yet read, on the device associated with fildes.
TCOFLUSH
Discard all data that's written, but not yet transmitted, on the device associated with fildes.
TCIOFLUSH
Discard all data that's written, but not yet transmitted, as well as all data that's received, but not yet read, on the device associated with fildes.

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

EBADF
Invalid fildes argument.
EINVAL
Invalid queue_selector argument.
ENOSYS
The resource manager associated with fildes doesn't support this call.
ENOTTY
The argument fildes doesn't refer to a terminal device.

Examples:

#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main( void )
  {
    int fildes;

    fildes = open( "/dev/ser1", O_RDWR );

    /* Throw away all input data */
    tcflush( fildes, TCIFLUSH );

    close( fildes );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, tcdrain(), tcflow(), tcsendbreak()


[Previous] [Contents] [Index] [Next]