tcflow()

Updated: May 06, 2022

Perform a flow-control operation on a data stream

Synopsis:

#include <termios.h>

int tcflow( int filedes, 
            int action );

Arguments:

filedes
A file descriptor that's associated with the data stream that you want to perform the operation on.
action
The action you want to perform; see below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The tcflow() function performs a flow-control operation on the data stream associated with filedes, depending on the values in action.

At least the following actions are defined in <termios.h>:

TCOOFF
Use software flow control to suspend output on the device associated with filedes.
TCOOFFHW
Use hardware flow control to suspend output on the device associated with filedes.
TCOON
Use software flow control to resume output on the device associated with filedes.
TCOONHW
Use hardware flow control to resume output on the device associated with filedes.
TCIOFF
Cause input to be flow-controlled by sending a STOP character immediately across the communication line associated with filedes, (that is, software flow control).
TCIOFFHW
Cause input to be flow-controlled by using hardware control.
TCION
Resume input by sending a START character immediately across the communication line associated with filedes (that is, software flow control).
TCIONHW
Cause input to be resumed by using hardware flow control.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

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

Examples:

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

int main( void )
  {
    int fd;

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

    /* Resume output on flow-controlled device */
    tcflow( fd, TCOON );

    close( fd );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

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