TTYLD(4) TTYLD(4) NAME tty_ld - terminal processing line discipline SYNOPSIS #include <sys/ttyio.h> DESCRIPTION Tty_ld is usually inserted into a stream connected to a ter- minal device. It gathers input into lines, handles special characters like erase, kill, and interrupt, inserts output delays, and the like. It does not deal with hardware param- eters such as speed and parity; see tty(4) for such matters. Certain special characters have particular meaning on input. These characters are not passed to a program except in raw mode, where they lose their special character. It is possi- ble to change these characters from the default. The erase character (backspace by default) erases the last- typed character. It will not erase beyond the beginning of a line or an end-of-file character. The kill character (default @) erases the entire preceding part of the line, but not beyond an end-of-file character. The end-of-file character (default control-d) causes any characters waiting to be read to be passed immediately to the program, without waiting for newline. The end-of-file character itself is discarded. Thus if the end-of-file character occurs at the beginning of a line, there are no characters waiting, and zero characters will be passed back; this is the standard end-of-file indication. The escape character (\) escapes a following erase, kill, or end-of-file character and allows it to be treated as ordi- nary data. The interrupt character (default DEL) is not passed to a program but sends signal `SIGINT' to any processes in the process group of the stream; see signal(2) and stream(4). The quit character (default FS, control-\) sends signal SIGQUIT. The stop character (default DC3, control-s) delays printing on the terminal until something is typed in. The start character (default DC1, control-q) restarts print- ing after a stop character without generating any input to a program. TTYLD(4) TTYLD(4) Two ioctl(2) calls affect these characters: TIOCGETC The argument points to a tchars structure to be filled in with current settings. TIOCSETC The argument points to a tchars structure from which the characters are set. The tchars structure, as defined in `<sys/ttyio.h>', is struct tchars { char t_intrc; /* interrupt */ char t_quitc; /* quit */ char t_startc; /* start output */ char t_stopc; /* stop output */ char t_eofc; /* end-of-file */ char t_brkc; /* input delimiter (like nl) */ }; A character value of 0377 eliminates the effect of that character. The `t_brkc' character, by default 0377, acts like a new-line in that it terminates a line, is echoed, and is passed to the program. The stop and start characters may be the same, to produce a toggle effect. It is counterpro- ductive to make other special characters (including erase and kill) identical. Two ioctl calls affect other terminal processing parameters: TIOCGETP The argument points to a sgttyb structure to be filled in with the current settings. TIOCSETP The argument points to a sgttyb structure from which the parameters are set. The sgttyb structure, as defined in `<sys/ttyio.h>', is struct sgttyb { char sg_ispeed;/* unused */ char sg_ospeed;/* unused */ char sg_erase; /* erase character */ char sg_kill; /* kill character */ short sg_flags; /* mode flags */ }; The flag bits are ALLDELAY 0177400 Delay algorithm selection VTDELAY 0040000 Form-feed and vertical-tab delays: FF0 0 FF1 0040000 CRDELAY 0030000 Carriage-return delays: CR0 0 CR1 0010000 CR2 0020000 TTYLD(4) TTYLD(4) CR3 0030000 TBDELAY 0006000 Tab delays: TAB0 0 TAB1 0002000 TAB2 0004000 XTABS 0006000 NLDELAY 0001400 New-line delays: NL0 0 NL1 0000400 NL2 0001000 NL3 0001400 RAW 0000040 Raw mode: wake up on all characters CRMOD 0000020 Map CR into LF; echo LF or CR as CR-LF ECHO 0000010 Echo (full duplex) LCASE 0000004 Map upper case to lower on input CBREAK 0000002 Return each character as soon as typed TANDEM 0000001 Automatic flow control The delay bits specify how long transmission stops to allow for mechanical or other movement when certain characters are sent to the terminal. In all cases a value of 0 indicates no delay. If a form-feed/vertical tab delay is specified, it lasts for about 2 seconds. Carriage-return delay type 1 lasts about .08 seconds; type 2 about .16 seconds; type 3 about .32 seconds. New-line delay type 1 is supposed to be for the Teletype model 37; type 2 is about .10 seconds. Tab delay type 1 is supposed to be for the Teletype model 37. Type 3, called `XTABS', is not a delay at all but causes tabs to be replaced by the appropriate number of spaces on output. In RAW mode, every character is passed immediately to the program without waiting until a full line has been typed. No erase or kill processing is done; the end-of-file, inter- rupt, and quit characters are not treated specially. There are no delays and no echoing, and no replacement of one character for another. `CRMOD' causes input carriage returns to be turned into new-lines; input of either CR or LF causes CR-LF both to be echoed (for terminals without a new-line function). `CBREAK' is a sort of half-cooked mode. Programs read each character as soon as typed, instead of waiting for a full line, but quit and interrupt work, and output delays `CRMOD', `XTABS', and `ECHO' work normally. On the other TTYLD(4) TTYLD(4) hand there is no erase or kill, and no special treatment of `\' or end-of-file. `TANDEM' mode causes the system to transmit the stop charac- ter whenever the input queue is in danger of overflowing, and the start character when the input queue has drained sufficiently. It is useful for flow control when the `ter- minal' is actually another machine that obeys the conven- tions. SEE ALSO getty(8), stty(1), signal(2), ioctl(2), stream(4), tty(4) BUGS The escape character cannot be changed.