ptg10805159
678 Te rminal I/O Chapter 18
18.3 Special Input Characters
POSIX.1 defines 11characters that arehandled specially on input. Implementations
define additional special characters. Figure18.9 summarizes these special characters.
c_cc Enabled by Typical FreeBSD Linux Mac OS X Solaris
Character Description subscript field flag value POSIX.1 8.0 3.2.0 10.6.8 10
CR carriagereturn (can’t change)c_lflag ICANON \r •••• •
DISCARD discardoutput VDISCARD c_lflag IEXTEN ˆO • •• •
DSUSP delayed suspend VDSUSP c_lflag ISIG ˆY • ••
(SIGTSTP)
EOF end of file VEOF c_lflag ICANON ˆD • •• ••
EOL end of line VEOL c_lflag ICANON •••• •
EOL2 alternate end of line VEOL2 c_lflag ICANON •• ••
ERASE backspace one VERASE c_lflag ICANON ˆH, ˆ? •••• •
character
ERASE2 alternate backspace VERASE2 c_lflag ICANON ˆH, ˆ? •
character
INTR interrupt signal VINTR c_lflag ISIG ˆ?, ˆC •••• •
(SIGINT)
KILL erase line VKILL c_lflag ICANON ˆU • •• ••
LNEXT literal next VLNEXT c_lflag IEXTEN ˆV • •• •
NL line feed (newline) (can’t change)c_lflag ICANON \n •••• •
QUIT quit signal (SIGQUIT)VQUIT c_lflag ISIG ˆ\ • •• ••
REPRINT reprint all input VREPRINT c_lflag ICANON ˆR • •• •
STARTresume output VSTART c_iflag IXON/IXOFF ˆQ • •• ••
STATUS statusrequest VSTATUS c_lflag ICANON ˆT • •
STOP stop output VSTOP c_iflag IXON/IXOFF ˆS • •• ••
SUSP suspend signal VSUSP c_lflag ISIG ˆZ • •• ••
(SIGTSTP)
WERASE backspace one word VWERASE c_lflag ICANON ˆW • •• •
Figure 18.9 Summary of special terminal input characters
Of the 11POSIX.1 special characters, we can change 9 of them to almost any value
that we like. The exceptions arethe newline and carriage return characters (\nand\r,
respectively) and perhaps the STOP and STARTcharacters (depends on the
implementation). To do this, we modify the appropriate entry in thec_ccarray of the
termiosstructure. The elements in this array arereferred to by name, with each name
beginning with aV(the thirdcolumn in Figure18.9).
POSIX.1 allows us to disable these characters. If we set the value of an entry in the
c_ccarray to the value of_POSIX_VDISABLE,then we disable the corresponding
special character.
In early versions of the Single UNIX Specification, support for_POSIX_VDISABLEwas optional.
It is now required.
All four platforms discussed in this text support this feature. Linux 3.2.0 and Solaris 10 define
_POSIX_VDISABLEas 0; FreeBSD 8.0 and Mac OS X 10.6.8 define it as0xff.
Some earlier UNIX systems disabled a feature if the corresponding special input character was 0.