Manual Page Result
0
Command: ttyld | Section: 4 | Source: UNIX v10 | File: ttyld.4
TTYLD(4) Kernel Interfaces Manual 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 terminal de-
vice. 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 parameters 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 possible to change these charac-
ters from the default.
The erase character (backspace by default) erases the last-typed char-
acter. 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 ordinary data.
The interrupt character (default DEL) is not passed to a program but
sends signal 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 ter-
minal until something is typed in.
The start character (default DC1, control-q) restarts printing after a
stop character without generating any input to a program.
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 charac-
ters are set.
The tchars structure, as defined in 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
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 counter-
productive 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 parame-
ters are set.
The sgttyb structure, as defined in 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
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 mechan-
ical or other movement when certain characters are sent to the termi-
nal. 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 is not a delay at all but causes tabs to be replaced by the ap-
propriate number of spaces on output.
In RAW mode, every character is passed immediately to the program with-
out waiting until a full line has been typed. No erase or kill pro-
cessing is done; the end-of-file, interrupt, and quit characters are
not treated specially. There are no delays and no echoing, and no re-
placement of one character for another.
causes input carriage returns to be turned into new-lines; input of ei-
ther CR or LF causes CR-LF both to be echoed (for terminals without a
new-line function).
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 and work normally. On the other hand there is no
erase or kill, and no special treatment of or end-of-file.
mode causes the system to transmit the stop character whenever the in-
put 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 `terminal' 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.
TTYLD(4)