termios, tcgetattr, tcsetattr, cfgetispeed, cfgetospeed, cfsetispeed,
cfsetospeed, tcsendbreak, tcdrain, tcflush, tcflow - change terminal
int tcgetattr(int fd, struct termios *tp)
int tcsetattr(int fd, int action, const struct termios *tp)
speed_t cfgetispeed(const struct termios *tp)
speed_t cfgetospeed(const struct termios *tp)
int cfsetispeed(struct termios *tp, speed_t speed)
int cfsetospeed(struct termios *tp, speed_t speed)
int tcsendbreak(int fd, int duration)
int tcdrain(int fd)
int tcflush(int fd, int queue_selector)
int tcflow(int fd, int action)
These are the user functions that modify the tty attributes mentioned in
tty(4). In the following, fd refers to an open terminal device file, tp
is the address of a struct termios, and speed and values of type speed_t
are equal to one of the B0, B50, etc. baud rate symbols. All functions,
symbols, and types are declared in <termios.h>.
The effects of the tty functions are:
Get the current settings of the tty attributes.
tcsetattr(fd, TCSANOW, tp)
Set the terminal attributes. The change occurs immediately.
tcsetattr(fd, TCSADRAIN, tp)
Set the terminal attributes. The change occurs once all the output
waiting in the output queues has been transmitted. This should be
used when options affecting output are changed.
tcsetattr(fd, TCSAFLUSH, tp)
Set the terminal attributes. But first wait until all the output
waiting in the output queues has been transmitted. All input
waiting in the input queues is then discarded and the change is
made. This should be used when switching from canonical to non-
canonical mode or vice-versa. (Oddly enough, this is seldom what
you want, because it discards typeahead. An editing shell does the
Right Thing if it uses TCSANOW instead. POSIX may not guarantee
good results, but in practice most systems make the canonical input
available in raw mode.)
Return the input baud rate encoded in the termios structure.
Return the output baud rate encoded in the termios structure.
Encode the new input baud rate into the termios structure.
Encode the new output baud rate into the termios structure.
Emit a break condition on a serial line for a time indicated by
duration. (Always 0.4 seconds under Minix, duration is ignored.)
Wait until all output waiting in the output queues has been
Flush the input queue. (I.e. discard it.)
Flush the output queue.
Flush the input and output queues.
Suspend output. (Like the effect of STOP.)
Restart output. (Like the effect of START.)
Transmit a STOP character intended to make the remote device stop
Transmit a START character to restart the remote device.
All functions return 0 unless otherwise specified, and -1 on error with
errno set to indicate the type of error. The most notable errors are
ENOTTY if fd does not refer to a terminal device, and EINTR if one of the
functions waiting for output to drain is interrupted.
It may be interesting to know that the functions operating on the tty are
directly translated into the following Minix ioctl requests: TCGETS,
TCSETS (now), TCSETSW (drain), TCSETSF, (flush), TCSBRK, TCDRAIN, TCFLSH,
and TCFLOW. You should only use this knowledge when trying to understand
the tty driver code, of course.
Kees J. Bot (email@example.com)