Team BBL
Previous Page Next Page

18.8. Line Control Functions

The following four functions provide line control capability for terminal devices. All four require that filedes refer to a terminal device; otherwise, an error is returned with errno set to ENOTTY.

#include <termios.h>

int tcdrain(int filedes);

int tcflow(int filedes, int action);

int tcflush(int filedes, int queue);

int tcsendbreak(int filedes, int duration);

All four return: 0 if OK, 1 on error


The tcdrain function waits for all output to be transmitted. The tcflow function gives us control over both input and output flow control. The action argument must be one of the following four values:

TCOOFF

Output is suspended.

TCOON

Output that was previously suspended is restarted.

TCIOFF

The system transmits a STOP character, which should cause the terminal device to stop sending data.

TCION

The system transmits a START character, which should cause the terminal device to resume sending data.


The tcflush function lets us flush (throw away) either the input buffer (data that has been received by the terminal driver, which we have not read) or the output buffer (data that we have written, which has not yet been transmitted). The queue argument must be one of the following three constants:

TCIFLUSH

The input queue is flushed.

TCOFLUSH

The output queue is flushed.

TCIOFLUSH

Both the input and the output queues are flushed.


The tcsendbreak function transmits a continuous stream of zero bits for a specified duration. If the duration argument is 0, the transmission lasts between 0.25 seconds and 0.5 seconds. POSIX.1 specifies that if duration is nonzero, the transmission time is implementation dependent.

    Team BBL
    Previous Page Next Page