1TTY(4) Kernel Interfaces Manual TTY(4)
2
3
4
6 tty - general terminal interface
7
9 #include <sgtty.h>
10
12 This section describes both a particular special file /dev/tty and the
13 terminal drivers used for conversational computing.
14
15 Line disciplines.
16
17 The system provides different line disciplines for controlling communi‐
18 cations lines. In this version of the system there are two disciplines
19 available for use with terminals:
20
21 old The old (Version 7) terminal driver. This is sometimes used
22 when using the standard shell sh(1).
23
24 new The standard Berkeley terminal driver, with features for job
25 control; this must be used when using csh(1).
26
27 Line discipline switching is accomplished with the TIOCSETD ioctl:
28
29 int ldisc = LDISC;
30 ioctl(f, TIOCSETD, &ldisc);
31
32 where LDISC is OTTYDISC for the standard tty driver and NTTYDISC for
33 the ``new'' driver. The standard (currently old) tty driver is disci‐
34 pline 0 by convention. Other disciplines may exist for special pur‐
35 poses, such as use of communications lines for network connections.
36 The current line discipline can be obtained with the TIOCGETD ioctl.
37 Pending input is discarded when the line discipline is changed.
38
39 All of the low-speed asynchronous communications ports can use any of
40 the available line disciplines, no matter what hardware is involved.
41 The remainder of this section discusses the “old” and “new” disci‐
42 plines.
43
44 The control terminal.
45
46 When a terminal file is opened, it causes the process to wait until a
47 connection is established. In practice, user programs seldom open
48 these files; they are opened by getty(8) or rlogind(8C) and become a
49 user's standard input and output file.
50
51 If a process which has no control terminal opens a terminal file, then
52 that terminal file becomes the control terminal for that process. The
53 control terminal is thereafter inherited by a child process during a
54 fork(2), even if the control terminal is closed.
55
56 The file /dev/tty is, in each process, a synonym for a control terminal
57 associated with that process. It is useful for programs that wish to
58 be sure of writing messages on the terminal no matter how output has
59 been redirected. It can also be used for programs that demand a file
60 name for output, when typed output is desired and it is tiresome to
61 find out which terminal is currently in use.
62
63 A process can remove the association it has with its controlling termi‐
64 nal by opening the file /dev/tty and issuing an
65
66 ioctl(f, TIOCNOTTY, 0);
67
68 This is often desirable in server processes.
69
70 Process groups.
71
72 Command processors such as csh(1) can arbitrate the terminal between
73 different jobs by placing related jobs in a single process group and
74 associating this process group with the terminal. A terminal's associ‐
75 ated process group may be set using the TIOCSPGRP ioctl(2):
76
77 ioctl(fildes, TIOCSPGRP, &pgrp);
78
79 or examined using TIOCGPGRP, which returns the current process group in
80 pgrp. The new terminal driver aids in this arbitration by restricting
81 access to the terminal by processes which are not in the current
82 process group; see Job access control below.
83
84 Modes.
85
86 The terminal drivers have three major modes, characterized by the
87 amount of processing on the input and output characters:
88
89 cooked The normal mode. In this mode lines of input are collected
90 and input editing is done. The edited line is made available
91 when it is completed by a newline, or when the t_brkc charac‐
92 ter (normally undefined) or t_eofc character (normally an
93 EOT, control-D, hereafter ^D) is entered. A carriage return
94 is usually made synonymous with newline in this mode, and
95 replaced with a newline whenever it is typed. All driver
96 functions (input editing, interrupt generation, output pro‐
97 cessing such as tab expansion, etc.) are available in this
98 mode.
99
100 CBREAK This mode eliminates the character, word, and line editing
101 input facilities, making the input character available to the
102 user program as it is typed. Flow control, literal-next and
103 interrupt processing are still done in this mode. Output
104 processing is done.
105
106 RAW This mode eliminates all input processing and makes all input
107 characters available as they are typed; no output processing
108 is done either.
109
110 The style of input processing can also be very different when the ter‐
111 minal is put in non-blocking I/O mode; see the FNDELAY flag described
112 in fcntl(2). In this case a read(2) from the control terminal will
113 never block, but rather return an error indication (EWOULDBLOCK) if
114 there is no input available.
115
116 A process may also request that a SIGIO signal be sent it whenever
117 input is present and also whenever output queues fall below the low-
118 water mark. To enable this mode the FASYNC flag should be set using
119 fcntl(2).
120
121 Input editing.
122
123 A UNIX terminal ordinarily operates in full-duplex mode. Characters
124 may be typed at any time, even while output is occurring, and are only
125 lost when the system's character input buffers become completely
126 choked, which is rare, or when the user has accumulated the maximum
127 allowed number of input characters that have not yet been read by some
128 program. Currently this limit is 256 characters. In RAW mode, the
129 terminal driver throws away all input and output without notice when
130 the limit is reached. In CBREAK or cooked mode it refuses to accept
131 any further input and, if in the new line discipline, rings the termi‐
132 nal bell.
133
134 Input characters are normally accepted in either even or odd parity
135 with the parity bit being stripped off before the character is given to
136 the program. By clearing either the EVEN or ODD bit in the flags word
137 it is possible to have input characters with that parity discarded (see
138 the Summary below.)
139
140 In all of the line disciplines, it is possible to simulate terminal
141 input using the TIOCSTI ioctl, which takes, as its third argument, the
142 address of a character. The system pretends that this character was
143 typed on the argument terminal, which must be the control terminal
144 except for the super-user (this call is not in standard version 7
145 UNIX).
146
147 Input characters are normally echoed by putting them in an output queue
148 as they arrive. This may be disabled by clearing the ECHO bit in the
149 flags word using the stty(3C) call or the TIOCSETN or TIOCSETP ioctls
150 (see the Summary below).
151
152 In cooked mode, terminal input is processed in units of lines. A pro‐
153 gram attempting to read will normally be suspended until an entire line
154 has been received (but see the description of SIGTTIN in Job access
155 control and of FIONREAD in Summary, both below.) No matter how many
156 characters are requested in the read call, at most one line will be
157 returned. It is not, however, necessary to read a whole line at once;
158 any number of characters may be requested in a read, even one, without
159 losing information.
160
161 During input, line editing is normally done, with the erase character
162 sg_erase (by default, DELETE) logically erasing the last character
163 typed and the sg_kill character (default, ^U: control-U) logically
164 erasing the entire current input line. These characters never erase
165 beyond the beginning of the current input line or an eof.
166
167 The drivers normally treat either a carriage return or a newline char‐
168 acter as terminating an input line, replacing the return with a newline
169 and echoing a return and a line feed. If the CRMOD bit is cleared in
170 the local mode word then the processing for carriage return is dis‐
171 abled, and it is simply echoed as a return, and does not terminate
172 cooked mode input.
173
174 In the new driver there is a literal-next character (normally ^V) which
175 can be typed in both cooked and CBREAK mode preceding any character to
176 prevent its special meaning to the terminal handler.
177
178 The new terminal driver also provides two other editing characters in
179 normal mode. The word-erase character, normally ^W, erases the preced‐
180 ing word, but not any spaces before it. For the purposes of ^W, a word
181 is defined as a sequence of non-blank characters, with tabs counted as
182 blanks. Finally, the reprint character, normally ^R, retypes the pend‐
183 ing input beginning on a new line. Retyping occurs automatically in
184 cooked mode if characters which would normally be erased from the
185 screen are fouled by program output.
186
187 Input echoing and redisplay
188
189 The terminal driver has several modes for handling the echoing of ter‐
190 minal input, controlled by bits in a local mode word.
191
192 Hardcopy terminals. When a hardcopy terminal is in use, the LPRTERA
193 bit is normally set in the local mode word. Characters which are logi‐
194 cally erased are then printed out backwards preceded by `\' and fol‐
195 lowed by `/' in this mode.
196
197 CRT terminals. When a CRT terminal is in use, the LCRTBS bit is nor‐
198 mally set in the local mode word. The terminal driver then echoes the
199 proper number of erase characters when input is erased; in the normal
200 case where the erase character is a ^H this causes the cursor of the
201 terminal to back up to where it was before the logically erased charac‐
202 ter was typed. If the input has become fouled due to interspersed
203 asynchronous output, the input is automatically retyped.
204
205 Erasing characters from a CRT. When a CRT terminal is in use, the
206 LCRTERA bit may be set to cause input to be erased from the screen with
207 a “backspace-space-backspace” sequence when character or word deleting
208 sequences are used. A LCRTKIL bit may be set as well, causing the
209 input to be erased in this manner on line kill sequences as well.
210
211 Echoing of control characters. If the LCTLECH bit is set in the local
212 state word, then non-printing (control) characters are normally echoed
213 as ^X (for some X) rather than being echoed unmodified; delete is
214 echoed as ^?.
215
216 The normal modes for use on CRT terminals are speed dependent. At
217 speeds less than 1200 baud, the LCRTERA and LCRTKILL processing is
218 painfully slow, and stty(1) normally just sets LCRTBS and LCTLECH; at
219 speeds of 1200 baud or greater all of these bits are normally set.
220 Stty(1) summarizes these option settings and the use of the new termi‐
221 nal driver as “newcrt.”
222
223 Output processing.
224
225 When one or more characters are written, they are actually transmitted
226 to the terminal as soon as previously-written characters have finished
227 typing. (As noted above, input characters are normally echoed by
228 putting them in the output queue as they arrive.) When a process pro‐
229 duces characters more rapidly than they can be typed, it will be sus‐
230 pended when its output queue exceeds some limit. When the queue has
231 drained down to some threshold the program is resumed. Even parity is
232 normally generated on output. The EOT character is not transmitted in
233 cooked mode to prevent terminals that respond to it from hanging up;
234 programs using RAW or CBREAK mode should be careful.
235
236 The terminal drivers provide necessary processing for cooked and CBREAK
237 mode output including parity generation. The driver will also option‐
238 ally expand tabs into spaces, where the tab stops are assumed to be set
239 every eight columns, and optionally convert newlines to carriage
240 returns followed by newline. These functions are controlled by bits in
241 the tty flags word; see Summary below.
242
243 Finally, in the new terminal driver, there is a output flush character,
244 normally ^O, which sets the LFLUSHO bit in the local mode word, causing
245 subsequent output to be flushed until it is cleared by a program or
246 more input is typed. This character has effect in both cooked and
247 CBREAK modes and causes pending input to be retyped if there is any
248 pending input. An ioctl to flush the characters in the input or output
249 queues, TIOCFLUSH, is also available.
250
251 Flow control.
252
253 There are two characters (the stop character, normally ^S, and the
254 start character, normally ^Q) which cause output to be suspended and
255 resumed respectively. Extra stop characters typed when output is
256 already stopped have no effect, unless the start and stop characters
257 are made the same, in which case output resumes.
258
259 A bit in the flags word may be set to put the terminal into TANDEM
260 mode. In this mode the system produces a stop character (default ^S)
261 when the input queue is in danger of overflowing, and a start character
262 (default ^Q) when the input has drained sufficiently. This mode is
263 useful when the terminal is actually another machine that obeys those
264 conventions.
265
266 If software flow control is not sufficient (it begins failing above
267 4800 bits per second on slow systems) RTS/CTS flow control is now
268 available. Hardware flow control causes RTS to be dropped when the
269 remote system (modem) should cease sending and to be raised when addi‐
270 tional data can be accepted. If the remote system drops CTS then the
271 local host ceases sending data until the CTS is raised. Hardware flow
272 control is enabled via the TIOCLBIS (or TIOCLBIC or TIOCLSET) function
273 and the bit LRTSCTS.
274
275 Line control and breaks.
276
277 There are several ioctl calls available to control the state of the
278 terminal line. The TIOCSBRK ioctl will set the break bit in the hard‐
279 ware interface causing a break condition to exist; this can be cleared
280 (usually after a delay with sleep(3)) by TIOCCBRK. Break conditions in
281 the input are reflected as a null character in RAW mode or as the
282 interrupt character in cooked or CBREAK mode. The TIOCCDTR ioctl will
283 clear the data terminal ready condition; it can be set again by TIOCS‐
284 DTR.
285
286 When the carrier signal from the dataset drops (usually because the
287 user has hung up his terminal) a SIGHUP hangup signal is sent to the
288 processes in the distinguished process group of the terminal; this usu‐
289 ally causes them to terminate. The SIGHUP can be suppressed by setting
290 the LNOHANG bit in the local state word of the driver. Access to the
291 terminal by other processes is then normally revoked, so any further
292 reads will fail, and programs that read a terminal and test for end-of-
293 file on their input will terminate appropriately.
294
295 It is possible to ask that the phone line be hung up on the last close
296 with the TIOCHPCL ioctl; this is normally done on the outgoing lines
297 and dialups.
298
299 Interrupt characters.
300
301 There are several characters that generate interrupts in cooked and
302 CBREAK mode; all are sent to the processes in the control group of the
303 terminal, as if a TIOCGPGRP ioctl were done to get the process group
304 and then a killpg(2) system call were done, except that these charac‐
305 ters also flush pending input and output when typed at a terminal
306 ('a`'la TIOCFLUSH). The characters shown here are the defaults; the
307 field names in the structures (given below) are also shown. The char‐
308 acters may be changed.
309
310 ^C t_intrc (ETX) generates a SIGINT signal. This is the normal way
311 to stop a process which is no longer interesting, or to regain
312 control in an interactive program.
313
314 ^\ t_quitc (FS) generates a SIGQUIT signal. This is used to cause
315 a program to terminate and produce a core image, if possible, in
316 the file core in the current directory.
317
318 ^Z t_suspc (EM) generates a SIGTSTP signal, which is used to sus‐
319 pend the current process group.
320
321 ^Y t_dsuspc (SUB) generates a SIGTSTP signal as ^Z does, but the
322 signal is sent when a program attempts to read the ^Y, rather
323 than when it is typed.
324
325 Job access control.
326
327 When using the new terminal driver, if a process which is not in the
328 distinguished process group of its control terminal attempts to read
329 from that terminal its process group is sent a SIGTTIN signal. This
330 signal normally causes the members of that process group to stop. If,
331 however, the process is ignoring SIGTTIN, has SIGTTIN blocked, or is in
332 the middle of process creation using vfork(2)), the read will return -1
333 and set errno to EIO.
334
335 When using the new terminal driver with the LTOSTOP bit set in the
336 local modes, a process is prohibited from writing on its control termi‐
337 nal if it is not in the distinguished process group for that terminal.
338 Processes which are holding or ignoring SIGTTOU signals or which are in
339 the middle of a vfork(2) are excepted and allowed to produce output.
340 Terminal/window sizes. In order to accommodate terminals and worksta‐
341 tions with variable-sized windows, the terminal driver provides a mech‐
342 anism for obtaining and setting the current terminal size. The driver
343 does not use this information internally, but only stores it and pro‐
344 vides a uniform access mechanism. When the size is changed, a SIGWINCH
345 signal is sent to the terminal's process group so that knowledgeable
346 programs may detect size changes. This facility was added in 4.3BSD
347 and is not available in earlier versions of the system.
348
349 Summary of modes.
350
351 Unfortunately, due to the evolution of the terminal driver, there are 4
352 different structures which contain various portions of the driver data.
353 The first of these (sgttyb) contains that part of the information
354 largely common between version 6 and version 7 UNIX systems. The sec‐
355 ond contains additional control characters added in version 7. The
356 third is a word of local state added in 4BSD, and the fourth is another
357 structure of special characters added for the new driver. In the
358 future a single structure may be made available to programs which need
359 to access all this information; most programs need not concern them‐
360 selves with all this state.
361
362 Basic modes: sgtty.
363
364 The basic ioctls use the structure defined in <sgtty.h>:
365
366 struct sgttyb {
367 char sg_ispeed;
368 char sg_ospeed;
369 char sg_erase;
370 char sg_kill;
371 shortsg_flags;
372 };
373
374 The sg_ispeed and sg_ospeed fields describe the input and output speeds
375 of the device according to the following table, which corresponds to
376 the DEC DH-11 interface. If other hardware is used, impossible speed
377 changes are ignored. Symbolic values in the table are as defined in
378 <sgtty.h>.
379
380 B0 0 (hang up dataphone)
381 B50 1 50 baud
382 B75 2 75 baud
383 B110 3 110 baud
384 B134 4 134.5 baud
385 B150 5 150 baud
386 B200 6 200 baud
387 B300 7 300 baud
388 B600 8 600 baud
389 B1200 9 1200 baud
390 B1800 10 1800 baud
391 B2400 11 2400 baud
392 B4800 12 4800 baud
393 B9600 13 9600 baud
394 EXTA 14 External A
395 EXTB 15 External B
396
397 Code conversion and line control required for IBM 2741's (134.5 baud)
398 must be implemented by the user's program. The half-duplex line disci‐
399 pline required for the 202 dataset (1200 baud) is not supplied; full-
400 duplex 212 datasets work fine.
401
402 The sg_erase and sg_kill fields of the argument structure specify the
403 erase and kill characters respectively. (Defaults are DELETE and ^U.)
404
405 The sg_flags field of the argument structure contains several bits that
406 determine the system's treatment of the terminal:
407
408 XTABS 0004000 Expand tabs on output
409 EVENP 0000200 Even parity allowed on input
410 ODDP 0000100 Odd parity allowed on input
411 RAW 0000040 Raw mode: wake up on all characters, 8-bit interface
412 CRMOD 0000020 Map CR into LF; output LF as CR-LF
413 ECHO 0000010 Echo (full duplex)
414 CBREAK 0000002 Return each character as soon as typed
415 TANDEM 0000001 Automatic inbound xon/xoff flow control
416
417 XTABS, causes tabs to be replaced by the appropriate number of spaces
418 on output.
419
420 The flags for even and odd parity control parity checking on input and
421 generation on output in cooked and CBREAK mode (unless LPASS8 is
422 enabled, see below). Even parity is generated on output unless ODDP is
423 set and EVENP is clear, in which case odd parity is generated. Input
424 characters with the wrong parity, as determined by EVENP and ODDP, are
425 ignored in cooked and CBREAK mode.
426
427 RAW disables all processing save output flushing with LFLUSHO; full 8
428 bits of input are given as soon as it is available; all 8 bits are
429 passed on output. A break condition in the input is reported as a null
430 character. If the input queue overflows in raw mode all data in the
431 input and output queues are discarded; this applies to both new and old
432 drivers.
433
434 CRMOD causes input carriage returns to be turned into new-lines, and
435 output and echoed new-lines to be output as a carriage return followed
436 by a line feed.
437
438 CBREAK is a sort of half-cooked (rare?) mode. Programs can read each
439 character as soon as typed, instead of waiting for a full line; all
440 processing is done except the input editing: character and word erase
441 and line kill, input reprint, and the special treatment of \ and EOT
442 are disabled.
443
444 TANDEM mode causes the system to produce a stop character (default ^S)
445 whenever the input queue is in danger of overflowing, and a start char‐
446 acter (default ^Q) when the input queue has drained sufficiently. It
447 is useful for flow control when the `terminal' is really another com‐
448 puter which understands the conventions.
449
450 Note: The same ``stop'' and ``start'' characters are used for both
451 directions of flow control; the t_stopc character is accepted on input
452 as the character that stops output and is produced on output as the
453 character to stop input, and the t_startc character is accepted on
454 input as the character that restarts output and is produced on output
455 as the character to restart input.
456
457 Basic ioctls
458
459 A large number of ioctl(2) calls apply to terminals. Some have the
460 general form:
461
462 #include <sgtty.h>
463
464 ioctl(fildes, code, arg)
465 struct sgttyb *arg;
466
467 The applicable codes are:
468
469 TIOCGETP Fetch the basic parameters associated with the terminal,
470 and store in the pointed-to sgttyb structure.
471
472 TIOCSETP Set the parameters according to the pointed-to sgttyb
473 structure. The interface delays until output is quies‐
474 cent, then throws away any unread characters, before
475 changing the modes.
476
477 TIOCSETN Set the parameters like TIOCSETP but do not delay or
478 flush input. Input is not preserved, however, when
479 changing to or from RAW.
480
481 With the following codes arg is ignored.
482
483 TIOCEXCL Set “exclusive-use” mode: no further opens are permitted
484 until the file has been closed.
485
486 TIOCNXCL Turn off “exclusive-use” mode.
487
488 TIOCHPCL When the file is closed for the last time, hang up the
489 terminal. This is useful when the line is associated
490 with an ACU used to place outgoing calls.
491
492 With the following codes arg is a pointer to an int.
493
494 TIOCGETD arg is a pointer to an int into which is placed the cur‐
495 rent line discipline number.
496
497 TIOCSETD arg is a pointer to an int whose value becomes the cur‐
498 rent line discipline number.
499
500 TIOCFLUSH If the int pointed to by arg has a zero value, all char‐
501 acters waiting in input or output queues are flushed.
502 Otherwise, the value of the int is for the FREAD and
503 FWRITE bits defined in <sys/file.h>; if the FREAD bit is
504 set, all characters waiting in input queues are flushed,
505 and if the FWRITE bit is set, all characters waiting in
506 output queues are flushed.
507
508 The remaining calls are not available in vanilla version 7 UNIX. In
509 cases where arguments are required, they are described; arg should oth‐
510 erwise be given as 0.
511
512 TIOCSTI the argument points to a character which the system pre‐
513 tends had been typed on the terminal.
514
515 TIOCSBRK the break bit is set in the terminal.
516
517 TIOCCBRK the break bit is cleared.
518
519 TIOCSDTR data terminal ready is set.
520
521 TIOCCDTR data terminal ready is cleared.
522
523 TIOCSTOP output is stopped as if the ``stop'' character had been
524 typed.
525
526 TIOCSTART output is restarted as if the ``start'' character had
527 been typed.
528
529 TIOCGPGRP arg is a pointer to an int into which is placed the
530 process group ID of the process group for which this
531 terminal is the control terminal.
532
533 TIOCSPGRP arg is a pointer to an int which is the value to which
534 the process group ID for this terminal will be set.
535
536 TIOCOUTQ returns in the int pointed to by arg the number of char‐
537 acters queued for output to the terminal.
538
539 FIONREAD returns in the long pointed to by arg the number of
540 characters immediately readable from the argument
541 descriptor. This works for files, pipes, and terminals.
542
543 Tchars
544
545 The second structure associated with each terminal specifies characters
546 that are special in both the old and new terminal interfaces: The fol‐
547 lowing structure is defined in <sys/ioctl.h>, which is automatically
548 included in <sgtty.h>:
549
550 struct tchars {
551 char t_intrc; /* interrupt */
552 char t_quitc; /* quit */
553 char t_startc; /* start output */
554 char t_stopc; /* stop output */
555 char t_eofc; /* end-of-file */
556 char t_brkc; /* input delimiter (like nl) */
557 };
558
559 The default values for these characters are ^C, ^\, ^Q, ^S, ^D, and -1.
560 A character value of -1 eliminates the effect of that character. The
561 t_brkc character, by default -1, acts like a new-line in that it termi‐
562 nates a `line,' is echoed, and is passed to the program. The `stop'
563 and `start' characters may be the same, to produce a toggle effect. It
564 is probably counterproductive to make other special characters (includ‐
565 ing erase and kill) identical. The applicable ioctl calls are:
566
567 TIOCGETC Get the special characters and put them in the specified
568 structure.
569
570 TIOCSETC Set the special characters to those given in the structure.
571
572 Local mode
573
574 The third structure associated with each terminal is a local mode word.
575 The bits of the local mode word are:
576
577 LCRTBS 000001 Backspace on erase rather than echoing erase
578 LPRTERA 000002 Printing terminal erase mode
579 LCRTERA 000004 Erase character echoes as backspace-space-backspace
580 LMDMBUF 000020 Stop/start output when carrier drops
581 LLITOUT 000040 Suppress output translations
582 LTOSTOP 000100 Send SIGTTOU for background output
583 LFLUSHO 000200 Output is being flushed
584 LNOHANG 000400 Don't send hangup when carrier drops
585 LRTSCTS 001000 RTS/CTS flow control
586 LCRTKIL 002000 BS-space-BS erase entire line on line kill
587 LPASS8 004000 Pass all 8 bits through on input, in any mode
588 LCTLECH 010000 Echo input control chars as ^X, delete as ^?
589 LPENDIN 020000 Retype pending input at next read or input character
590 LDECCTQ 040000 Only ^Q restarts output after ^S, like DEC systems
591 LNOFLSH 100000 Inhibit flushing of pending I/O when an interrupt character is typed.
592
593 The applicable ioctl functions are:
594
595 TIOCLBIS arg is a pointer to an int whose value is a mask con‐
596 taining the bits to be set in the local mode word.
597
598 TIOCLBIC arg is a pointer to an int whose value is a mask con‐
599 taining the bits to be cleared in the local mode word.
600
601 TIOCLSET arg is a pointer to an int whose value is stored in the
602 local mode word.
603
604 TIOCLGET arg is a pointer to an int into which the current local
605 mode word is placed.
606
607 Local special chars
608
609 The final control structure associated with each terminal is the
610 ltchars structure which defines control characters for the new terminal
611 driver. Its structure is:
612
613 struct ltchars {
614 char t_suspc; /* stop process signal */
615 char t_dsuspc; /* delayed stop process signal */
616 char t_rprntc; /* reprint line */
617 char t_flushc; /* flush output (toggles) */
618 char t_werasc; /* word erase */
619 char t_lnextc; /* literal next character */
620 };
621
622 The default values for these characters are ^Z, ^Y, ^R, ^O, ^W, and ^V.
623 A value of -1 disables the character.
624
625 The applicable ioctl functions are:
626
627 TIOCSLTC arg is a pointer to an ltchars structure which defines the
628 new local special characters.
629
630 TIOCGLTC arg is a pointer to an ltchars structure into which is
631 placed the current set of local special characters.
632
633 Window/terminal sizes
634
635 Each terminal has provision for storage of the current terminal or win‐
636 dow size in a winsize structure, with format:
637
638 struct winsize {
639 unsigned short ws_row; /* rows, in characters */
640 unsigned short ws_col; /* columns, in characters */
641 unsigned short ws_xpixel; /* horizontal size, pixels */
642 unsigned short ws_ypixel; /* vertical size, pixels */
643 };
644
645 A value of 0 in any field is interpreted as ``undefined;'' the entire
646 structure is zeroed on final close.
647
648 The applicable ioctl functions are:
649
650 TIOCGWINSZ
651 arg is a pointer to a struct winsize into which will be placed
652 the current terminal or window size information.
653
654 TIOCSWINSZ
655 arg is a pointer to a struct winsize which will be used to set
656 the current terminal or window size information. If the new
657 information is different than the old information, a SIGWINCH
658 signal will be sent to the terminal's process group.
659
661 /dev/tty
662 /dev/tty*
663 /dev/console
664
666 csh(1), stty(1), tset(1), ioctl(2), sigvec(2), stty(3C), getty(8)
667
668
669
6704th Berkeley Distribution April 10, 1997 TTY(4)