1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
.TH TTYLD 4
.CT 2 comm_term
.SH NAME
tty_ld \- terminal processing line discipline
.SH SYNOPSIS
.B #include <sys/ttyio.h>
.SH DESCRIPTION
.I Tty_ld
is usually inserted
into a stream
connected to a terminal 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 parameters
such as speed and parity;
see
.IR tty (4)
for such matters.
.PP
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 characters from the default.
.PP
The
.I erase
character
(default
.BR # )
erases the last-typed character.
It will not erase beyond the beginning of a line or
an end-of-file character.
.PP
The
.I kill
character
(default
.BR @ )
erases the entire preceding part of the line, but not beyond
an end-of-file character.
.PP
The
.I end-of-file
character
(default
.RB 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.
.PP
The
.I escape
character
.RB ( \e )
escapes a following erase, kill, or end-of-file character
and allows it to be treated as ordinary data.
.PP
The
.I interrupt
character
(default
DEL)
is not passed to a program but sends
signal
.L SIGINT
to any processes in the process group of the stream;
see
.IR signal (2)
and
.IR stream (4).
.PP
The
.I quit
character
(default
FS,
.RB control- \e )
sends signal
.BR SIGQUIT .
.PP
The
.I stop
character
(default DC3,
.RB control- s )
delays printing on the terminal
until something is typed in.
.PP
The
.I start
character
(default DC1,
.RB control- q )
restarts printing after
a stop character without generating
any input to a program.
.PP
Two
.IR ioctl (2)
calls affect these characters:
.TF TIOCGETC
.TP
.B TIOCGETC
The argument points to a
.B tchars
structure to be filled in with current settings.
.TP
.B TIOCSETC
The argument points to a
.B tchars
structure from which the characters are set.
.PD
.PP
The
.B tchars
structure, as defined in
.LR <sys/ttyio.h> ,
is
.PP
.EX
.ta \w'struct 'u +\w'tchars 'u +\w't_startc; 'u
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) */
};
.EE
.PP
A character value of 0377
eliminates the effect of that character.
The
.L 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 counterproductive to make
other special characters (including erase and kill)
identical.
.PP
Two
.I ioctl
calls affect other terminal processing parameters:
.TF TIOCGETP
.TP
.B TIOCGETP
The argument points to a
.B sgttyb
structure to be filled in with the current settings.
.TP
.B TIOCSETP
The argument points to a
.B sgttyb
structure from which the parameters are set.
.PD
.PP
The
.B sgttyb
structure, as
defined in
.LR <sys/ttyio.h> ,
is
.EX
.ta \w'struct 'u +\w'sgttyb 'u +\w'sg_ispeed 'u
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 */
};
.EE
.PP
The flag bits are
.PP
.ta \w'\f5ALLDELAY\fP 'u +\w'\f50100000\fP 'u
.nf
\f5ALLDELAY 0177400\fP Delay algorithm selection
\f5VTDELAY 0040000\fP Form-feed and vertical-tab delays:
\f5FF0 0\fP
\f5FF1 0040000\fP
\f5CRDELAY 0030000\fP Carriage-return delays:
\f5CR0 0\fP
\f5CR1 0010000\fP
\f5CR2 0020000\fP
\f5CR3 0030000\fP
\f5TBDELAY 0006000\fP Tab delays:
\f5TAB0 0\fP
\f5TAB1 0002000\fP
\f5TAB2 0004000\fP
\f5XTABS 0006000\fP
\f5NLDELAY 0001400\fP New-line delays:
\f5NL0 0\fP
\f5NL1 0000400\fP
\f5NL2 0001000\fP
\f5NL3 0001400\fP
\f5RAW 0000040\fP Raw mode: wake up on all characters
\f5CRMOD 0000020\fP Map CR into LF; echo LF or CR as CR-LF
\f5ECHO 0000010\fP Echo (full duplex)
\f5LCASE 0000004\fP Map upper case to lower on input
\f5CBREAK 0000002\fP Return each character as soon as typed
\f5TANDEM 0000001\fP Automatic flow control
.DT
.fi
.PP
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.
.PP
If a form-feed/vertical tab delay is specified,
it lasts for about 2 seconds.
.PP
Carriage-return delay type 1 lasts about .08 seconds;
type 2 about .16 seconds;
type 3 about .32 seconds.
.PP
New-line delay type 1 is supposed to be for the Teletype model 37;
type 2 is about .10 seconds.
.PP
Tab delay type 1 is supposed to be for the Teletype model 37.
Type 3, called
.LR XTABS ,
is not a delay at all but causes tabs to be replaced
by the appropriate number of spaces on output.
.PP
In
.B 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, interrupt, and quit characters
are not treated specially.
There are no delays and no echoing, and no replacement of
one character for another.
.PP
.L 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).
.PP
.L 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
.LR CRMOD ,
.LR XTABS ,
and
.LR ECHO
work normally.
On the other hand there is no erase or kill,
and no special treatment of
.L \e
or end-of-file.
.PP
.L TANDEM
mode causes the system to transmit
the stop character 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 `terminal'
is actually another machine that obeys the conventions.
.SH SEE ALSO
.IR getty (8),
.IR stty (1),
.IR signal (2),
.IR ioctl (2),
.IR stream (4),
.IR tty (4)
.SH BUGS
The
escape character
cannot be changed.
|