Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 18.2 Overview 677


Function Description
tcgetattr fetch attributes (termiosstructure)
tcsetattr set attributes (termiosstructure)
cfgetispeed get input speed
cfgetospeed get output speed
cfsetispeed set input speed
cfsetospeed set output speed
tcdrain wait for all output to be transmitted
tcflow suspend transmit or receive
tcflush flush pending input and/or output
tcsendbreak send BREAK character
tcgetpgrp get foreground process group ID
tcsetpgrp set foreground process group ID
tcgetsid get process group ID of session leader for controlling TTY

Figure 18.7 Summary of terminal I/O functions

The relationships among the 13 functions shown in Figure18.7 areillustrated in
Figure18.8.

input baud rate output baud rate
struct
termios

terminal line discipline / terminal device driver

cfsetispeedcfgetispeedcfsetospeedcfgetospeed

tcsetattr tcgetattr tcsendbreaktcdraintcflush

tcflow

line control functions

tcgetsidtcgetpgrptcsetpgrp

foreground
process group ID

Figure 18.8Relationships among the terminal-related functions

POSIX.1 doesn’t specify where in thetermiosstructurethe baud rate information is stored;
that is an implementation detail. Some systems, such as Solaris, storethis information in the
c_cflagfield. Linux and BSD-derived systems, such as FreeBSD and Mac OS X, have two
separate fields in the structure: one for the input speed and one for the output speed.
Free download pdf