Commit | Line | Data |
---|---|---|
02d430a1 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
d90ee9fb | 5 | .\" @(#)tty.4 6.1 (Berkeley) %G% |
02d430a1 | 6 | .\" |
d90ee9fb | 7 | .TH TTY 4 "" |
02d430a1 KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | tty \- general terminal interface | |
9313e78d KM |
11 | .SH SYNOPSIS |
12 | .B #include <sgtty.h> | |
02d430a1 KM |
13 | .SH DESCRIPTION |
14 | This section describes | |
15 | both a particular special file | |
16 | .B /dev/tty | |
17 | and the terminal drivers used for conversational computing. | |
18 | .LP | |
19 | .B Line disciplines. | |
20 | .PP | |
21 | The system provides different | |
22 | .I "line disciplines" | |
23 | for controlling communications lines. | |
24 | In this version of the system there are three disciplines available: | |
25 | .IP "old" 8 | |
26 | The old (standard) terminal driver. This is used when using the | |
27 | standard shell | |
28 | .IR sh (1) | |
29 | and for compatibility with other standard version 7 UNIX systems. | |
30 | .IP "new" | |
31 | A newer terminal driver, with features for job control; this must | |
32 | be used when using | |
33 | .IR csh (1). | |
02d430a1 KM |
34 | .IP "net" |
35 | A line discipline used for networking and loading data into | |
36 | the system over communications lines. It allows high speed input | |
37 | at very low overhead, and is described in | |
38 | .IR bk (4). | |
39 | .LP | |
40 | Line discipline switching is accomplished with the TIOCSETD | |
41 | .I ioctl: | |
42 | .IP | |
43 | .B "int ldisc = LDISC; ioctl(filedes, TIOCSETD, &ldisc);" | |
44 | .LP | |
45 | where LDISC is OTTYDISC for the standard tty driver, NTTYDISC for the new | |
46 | driver and NETLDISC for the networking discipline. | |
47 | The standard (currently old) tty driver is discipline 0 by convention. | |
48 | The current line discipline can be obtained with the TIOCGETD ioctl. | |
49 | Pending input is discarded when the line discipline is changed. | |
50 | .PP | |
51 | All of the low-speed asynchronous | |
52 | communications ports can use any | |
53 | of the available line disciplines, no matter what | |
54 | hardware is involved. | |
55 | The remainder of this section discusses the | |
56 | \*(lqold\*(rq and \*(lqnew\*(rq disciplines. | |
57 | .LP | |
58 | .B "The control terminal." | |
59 | .LP | |
60 | When a terminal file is opened, it causes the process to wait until a | |
61 | connection is established. In practice, user programs seldom open | |
62 | these files; they are opened by | |
63 | .IR init (8) | |
64 | and become a user's standard input and output file. | |
65 | .PP | |
66 | If a process which has no control terminal opens a terminal file, then | |
67 | that terminal file becomes the control terminal for that process. | |
68 | The control terminal is thereafter inherited by a child process during a | |
69 | .IR fork (2), | |
70 | even if the control terminal is closed. | |
71 | .LP | |
72 | The file | |
73 | .B /dev/tty | |
74 | is, in each process, a synonym for a | |
75 | .I "control terminal" | |
76 | associated with that process. It is useful for programs that wish to | |
77 | be sure of writing messages on the terminal | |
78 | no matter how output has been redirected. | |
79 | It can also be used for programs that demand a file name | |
80 | for output, when typed output is desired | |
81 | and it is tiresome to find out which terminal | |
82 | is currently in use. | |
83 | .LP | |
84 | .B "Process groups." | |
85 | .LP | |
9313e78d | 86 | Command processors such as |
02d430a1 KM |
87 | .IR csh (1) |
88 | can arbitrate the terminal between different | |
89 | .I jobs | |
90 | by placing related jobs in a single process group and associating this | |
91 | process group with the terminal. A terminals associated process group | |
92 | may be set using the TIOCSPGRP | |
93 | .IR ioctl (2): | |
94 | .IP | |
95 | \fBioctl(fildes, TIOCSPGRP, &pgrp)\fR | |
96 | .LP | |
97 | or examined using TIOCGPGRP rather than TIOCSPGRP, returning the current | |
98 | process group in | |
99 | .I pgrp. | |
100 | The new terminal driver aids in this arbitration by restricting access | |
101 | to the terminal by processes which are not in the current process group; | |
102 | see | |
103 | .B "Job access control" | |
104 | below. | |
105 | .LP | |
106 | .B "Modes." | |
107 | .PP | |
108 | The terminal drivers have three major modes, characterized by the | |
109 | amount of processing on the input and output characters: | |
110 | .IP cooked 10 | |
111 | The normal mode. In this mode lines of input are collected and input editing | |
112 | is done. The edited line is made available when it is completed by | |
113 | a newline | |
114 | or when an EOT (control-D, hereafter ^D) | |
115 | is entered. | |
116 | A carriage return is usually made synonymous with newline in this mode, | |
117 | and replaced with a newline whenever it is typed. | |
118 | All driver functions | |
119 | (input editing, interrupt generation, | |
120 | output processing such as delay generation and tab expansion, etc.) | |
121 | are available in this mode. | |
122 | .IP CBREAK 10 | |
123 | This mode eliminates the character, word, and line editing input facilities, | |
124 | making the input character available to the user program as it is typed. | |
125 | Flow control, literal-next and interrupt processing are still done in this mode. | |
126 | Output processing is done. | |
127 | .IP RAW 10 | |
128 | This mode eliminates all input processing and makes all input characters | |
129 | available as they are typed; no output processing is done either. | |
130 | .PP | |
9313e78d KM |
131 | The style of input processing can also be very different when |
132 | the terminal is put in non-blocking i/o mode; see | |
133 | .IR fcntl (2). | |
134 | In this case a | |
02d430a1 KM |
135 | .IR read (2) |
136 | from the control terminal will never block, but rather | |
9313e78d KM |
137 | return an error indication (EWOULDBLOCK) if there is no |
138 | input available. | |
139 | .PP | |
140 | A process may also request a SIGIO signal be sent it whenever input | |
141 | is present. To enable this mode the FASYNC flag should be set using | |
142 | .IR fcntl (2). | |
02d430a1 KM |
143 | .LP |
144 | .B "Input editing." | |
145 | .LP | |
146 | A UNIX terminal ordinarily operates in full-duplex mode. | |
147 | Characters may be typed at any time, | |
148 | even while output is occurring, and are only lost when the | |
149 | system's character input buffers become completely | |
150 | choked, which is rare, | |
151 | or when the user has accumulated the maximum allowed number of | |
152 | input characters that have not yet been read by some program. | |
153 | Currently this limit is 256 characters. | |
154 | In the old terminal driver all the saved characters are thrown away | |
155 | when the limit is reached, without notice; the new driver simply refuses | |
156 | to accept any further input, and rings the terminal bell. | |
157 | .PP | |
158 | Input characters are normally accepted in either even or odd parity | |
159 | with the parity bit being stripped off before the character is given to | |
160 | the program. By clearing either the EVEN or ODD bit in the flags word | |
161 | it is possible to have input characters with that parity discarded (see the | |
162 | \fBSummary\fR below.) | |
163 | .PP | |
164 | In all of the line disciplines, it is possible to simulate terminal | |
165 | input using the TIOCSTI ioctl, which takes, as its third argument, | |
166 | the address of a character. The system pretends that this character | |
167 | was typed on the argument terminal, which must be the control terminal except | |
9313e78d | 168 | for the super-user (this call is not in standard version 7 UNIX). |
02d430a1 KM |
169 | .PP |
170 | Input characters are normally echoed by putting them in an output queue | |
171 | as they arrive. This may be disabled by clearing the ECHO bit in the | |
172 | flags word using the | |
9313e78d | 173 | .IR stty (3) |
02d430a1 KM |
174 | call or the TIOCSETN or TIOCSETP ioctls |
175 | (see the \fBSummary\fR below). | |
176 | .PP | |
177 | In cooked mode, terminal input is processed in units of lines. | |
178 | A program attempting | |
179 | to read will normally be suspended until an entire line has been | |
180 | received | |
181 | (but see the description of SIGTTIN in \fBModes\fR above and FIONREAD in | |
182 | \fBSummary\fR below.) | |
183 | No matter how many characters are requested | |
184 | in the read call, at most one line will be returned. | |
185 | It is not, however, necessary to read a whole line at | |
186 | once; any number of characters may be | |
187 | requested in a read, even one, without losing information. | |
188 | .PP | |
189 | During input, line editing is normally done, with the character `#' | |
190 | logically erasing the last character typed and the character `@' | |
191 | logically erasing the entire current input line. | |
192 | These are often reset on crt's, | |
193 | with ^H replacing #, | |
194 | and ^U replacing @. | |
195 | These characters | |
196 | never erase beyond the beginning of the current input line or an ^D. | |
197 | These characters may be entered literally by | |
198 | preceding them with `\e\|'; in the old teletype driver both the `\e\|' and | |
199 | the character entered literally will appear on the screen; in the new | |
200 | driver the `\e\|' will normally disappear. | |
201 | .PP | |
202 | The drivers normally treat either a carriage return or a newline character | |
203 | as terminating an input line, replacing the return with a newline and echoing | |
204 | a return and a line feed. | |
205 | If the CRMOD bit is cleared in the local mode word then the processing | |
206 | for carriage return is disabled, and it is simply echoed as a return, | |
207 | and does not terminate cooked mode input. | |
208 | .PP | |
209 | In the new driver there is a literal-next character ^V which can be typed | |
210 | in both cooked and CBREAK mode preceding | |
211 | .B any | |
212 | character to prevent its special meaning. This is to be preferred to the | |
213 | use of `\e\|' escaping erase and kill characters, but `\e\|' is (at least | |
214 | temporarily) retained with its old function in the new driver for historical | |
215 | reasons. | |
216 | .PP | |
217 | The new terminal driver also provides two other editing characters in | |
218 | normal mode. The word-erase character, normally ^W, erases the preceding | |
219 | word, but not any spaces before it. For the purposes of ^W, a word | |
220 | is defined as a sequence of non-blank characters, with tabs counted as | |
221 | blanks. | |
222 | Finally, the reprint character, normally ^R, retypes the pending input beginning | |
9313e78d | 223 | on a new line. Retyping occurs automatically in cooked mode if characters |
02d430a1 KM |
224 | which would normally be erased from the screen are fouled by program output. |
225 | .LP | |
226 | .B "Input echoing and redisplay" | |
227 | .LP | |
228 | In the old terminal driver, nothing special occurs when an erase character | |
229 | is typed; the erase character is simply echoed. When a kill character | |
230 | is typed it is echoed followed by a new-line (even if the character is | |
231 | not killing the line, because it was preceded by a `\e\|'!.) | |
232 | .PP | |
233 | The new terminal driver has several modes for handling the echoing of | |
234 | terminal input, controlled by bits in a local mode word. | |
235 | .LP | |
236 | .I "Hardcopy terminals." | |
237 | When a hardcopy terminal is in use, the LPRTERA bit is normally set in | |
238 | the local mode word. Characters which are logically erased are | |
239 | then printed out backwards preceded by `\e\|' and followed by `/' in this mode. | |
240 | .LP | |
241 | .I "Crt terminals." | |
242 | When a crt terminal is in use, the LCRTBS bit is normally set in the local | |
243 | mode word. The terminal driver then echoes the proper number of erase | |
244 | characters when input is erased; in the normal case where the erase | |
245 | character is a ^H this causes the cursor of the terminal to back up | |
246 | to where it was before the logically erased character was typed. | |
247 | If the input has become fouled due to interspersed asynchronous output, | |
9313e78d | 248 | the input is automatically retyped. |
02d430a1 KM |
249 | .LP |
250 | .I "Erasing characters from a crt." | |
251 | When a crt terminal is in use, the LCRTERA bit may be set to cause | |
252 | input to be erased from the screen with a \*(lqbackspace-space-backspace\*(rq | |
253 | sequence when character or word deleting sequences are used. | |
254 | A LCRTKIL bit may be set as well, causing the input to | |
255 | be erased in this manner on line kill sequences as well. | |
256 | .LP | |
257 | .I "Echoing of control characters." | |
258 | If the LCTLECH bit is set in the local state word, then non-printing (control) | |
259 | characters are normally echoed as ^X (for some X) | |
260 | rather than being echoed unmodified; delete is echoed as ^?. | |
261 | .LP | |
262 | The normal modes for using the new terminal driver on crt terminals | |
263 | are speed dependent. | |
264 | At speeds less than 1200 baud, the LCRTERA and LCRTKILL processing | |
265 | is painfully slow, so | |
266 | .IR stty (1) | |
267 | normally just sets LCRTBS and LCTLECH; at | |
268 | speeds of 1200 baud or greater all of these bits are normally set. | |
269 | .IR Stty (1) | |
270 | summarizes these option settings and the use of the new terminal | |
271 | driver as | |
272 | \*(lqnewcrt.\*(rq | |
273 | .LP | |
274 | .B "Output processing." | |
275 | .PP | |
276 | When one or more | |
277 | characters are written, they are actually transmitted | |
278 | to the terminal as soon as previously-written characters | |
279 | have finished typing. | |
280 | (As noted above, input characters are normally | |
281 | echoed by putting them in the output queue | |
282 | as they arrive.) | |
283 | When a process produces characters more rapidly than they can be typed, | |
284 | it will be suspended when its output queue exceeds some limit. | |
285 | When the queue has drained down to some threshold | |
286 | the program is resumed. | |
287 | Even parity is normally generated on output. | |
288 | The EOT character is not transmitted in cooked mode to prevent terminals | |
289 | that respond to it from hanging up; programs using raw or cbreak mode | |
290 | should be careful. | |
291 | .PP | |
292 | The terminal drivers provide necessary processing for cooked and CBREAK mode | |
293 | output including delay generation for certain special characters and parity | |
294 | generation. Delays are available after backspaces ^H, form feeds ^L, | |
295 | carriage returns ^M, tabs ^I and newlines ^J. The driver will also optionally | |
296 | expand tabs into spaces, where the tab stops are assumed to be set every | |
297 | eight columns. These functions are controlled by bits in the tty flags word; | |
298 | see \fBSummary\fR below. | |
299 | .PP | |
300 | The terminal drivers provide for mapping between upper and lower case | |
301 | on terminals lacking lower case, and for other special processing on | |
302 | deficient terminals. | |
303 | .PP | |
304 | Finally, in the new terminal driver, there is a output flush character, | |
305 | normally ^O, which sets the LFLUSHO bit in the local mode word, causing | |
306 | subsequent output to be flushed until it is cleared by a program or more | |
307 | input is typed. This character has effect in both cooked and CBREAK modes | |
308 | and causes pending input to be retyped if there is any pending input. | |
9313e78d KM |
309 | An ioctl to flush the characters in the input and output queues TIOCFLUSH, |
310 | is also available. | |
02d430a1 KM |
311 | .LP |
312 | .B "Upper case terminals and Hazeltines" | |
313 | .PP | |
314 | If the LCASE bit is set in the tty flags, then | |
315 | all upper-case letters are mapped into | |
316 | the corresponding lower-case letter. | |
317 | The upper-case letter may be generated by preceding | |
318 | it by `\\'. | |
319 | If the new terminal driver is being used, | |
320 | then upper case letters | |
321 | are preceded by a `\e\|' when output. | |
322 | In addition, the following escape sequences can be generated | |
323 | on output and accepted on input: | |
324 | .PP | |
325 | .nf | |
326 | for \` | ~ { } | |
327 | use \e\|\' \e\|! \e\|^ \e\|( \e\|) | |
328 | .fi | |
329 | .PP | |
330 | To deal with Hazeltine terminals, which do not understand that ~ has | |
331 | been made into an ASCII character, the LTILDE bit may be set in the local | |
332 | mode word when using the new terminal driver; in this case the character | |
333 | ~ will be replaced with the character \` on output. | |
334 | .LP | |
335 | .B "Flow control." | |
336 | .PP | |
337 | There are two characters (the stop character, normally ^S, and the | |
338 | start character, normally ^Q) which cause output to be suspended and | |
339 | resumed respectively. Extra stop characters typed when output | |
340 | is already stopped have no effect, unless the start and stop characters | |
341 | are made the same, in which case output resumes. | |
342 | .PP | |
343 | A bit in the flags word may be set to put the terminal into TANDEM mode. | |
344 | In this mode the system produces a stop character (default ^S) when | |
345 | the input queue is in danger of overflowing, and a start character (default | |
346 | ^Q) when the input has drained sufficiently. This mode is useful | |
347 | when the terminal is actually another machine that obeys the | |
348 | conventions. | |
349 | .LP | |
350 | .B "Line control and breaks." | |
351 | .LP | |
352 | There are several | |
353 | .I ioctl | |
354 | calls available to control the state of the terminal line. | |
355 | The TIOCSBRK ioctl will set the break bit in the hardware interface | |
356 | causing a break condition to exist; this can be cleared (usually after a delay | |
357 | with | |
358 | .IR sleep (3)) | |
359 | by TIOCCBRK. | |
360 | Break conditions in the input are reflected as a null character in RAW mode | |
361 | or as the interrupt character in cooked or CBREAK mode. | |
362 | The TIOCCDTR ioctl will clear the data terminal ready condition; it can | |
363 | be set again by TIOCSDTR. | |
364 | .PP | |
365 | When the carrier signal from the dataset drops (usually | |
366 | because the user has hung up his terminal) a | |
367 | SIGHUP hangup signal is sent to the processes in the distinguished | |
368 | process group of the terminal; this usually causes them to terminate | |
369 | (the SIGHUP can be suppressed by setting the LNOHANG bit in the local | |
370 | state word of the driver.) | |
371 | Access to the terminal by other processes is then normally revoked, | |
372 | so any further reads will fail, and programs that read a terminal and test for | |
373 | end-of-file on their input will terminate appropriately. | |
374 | .PP | |
375 | When using an ACU | |
376 | it is possible to ask that the phone line be hung up on the last close | |
377 | with the TIOCHPCL ioctl; this is normally done on the outgoing line. | |
378 | .LP | |
379 | .B "Interrupt characters." | |
380 | .PP | |
381 | There are several characters that generate interrupts in cooked and CBREAK | |
382 | mode; all are sent the processes in the control group of the terminal, | |
383 | as if a TIOCGPGRP ioctl were done to get the process group and then a | |
384 | .IR killpg (2) | |
385 | system call were done, | |
386 | except that these characters also flush pending input and output when | |
387 | typed at a terminal | |
388 | (\fI\z'a\`'la\fR TIOCFLUSH). | |
389 | The characters shown here are the defaults; the field names in the structures | |
390 | (given below) | |
391 | are also shown. | |
392 | The characters may be changed, | |
393 | although this is not often done. | |
394 | .IP ^? | |
9313e78d | 395 | \fBt_intrc\fR (Delete) generates a SIGINT signal. |
02d430a1 KM |
396 | This is the normal way to stop a process which is no longer interesting, |
397 | or to regain control in an interactive program. | |
398 | .IP ^\e | |
399 | \fBt_quitc\fR (FS) generates a SIGQUIT signal. | |
400 | This is used to cause a program to terminate and produce a core image, | |
401 | if possible, | |
402 | in the file | |
403 | .B core | |
404 | in the current directory. | |
405 | .IP ^Z | |
406 | \fBt_suspc\fR (EM) generates a SIGTSTP signal, which is used to suspend | |
407 | the current process group. | |
408 | .IP ^Y | |
9313e78d | 409 | \fBt_dsuspc\fR (SUB) generates a SIGTSTP signal as ^Z does, but the |
02d430a1 KM |
410 | signal is sent when a program attempts to read the ^Y, rather than when |
411 | it is typed. | |
412 | .LP | |
413 | .B "Job access control." | |
414 | .PP | |
415 | When using the new terminal driver, | |
416 | if a process which is not in the distinguished process group of its | |
417 | control terminal attempts to read from that terminal its process group is | |
9313e78d KM |
418 | sent a SIGTTIN signal. This signal normally causes the members of |
419 | that process group to stop. | |
420 | If, however, the process is ignoring SIGTTIN, has SIGTTIN blocked, | |
421 | is an | |
422 | .IR "orphan process" , | |
423 | or is in the middle of process creation using | |
02d430a1 | 424 | .IR vfork (2)), |
9313e78d KM |
425 | it is instead returned an end-of-file. (An |
426 | .I "orphan process" | |
427 | is a process whose | |
428 | parent has exited and has been inherited by the | |
429 | .IR init (8) | |
430 | process.) | |
431 | Under older UNIX systems | |
02d430a1 KM |
432 | these processes would typically have had their input files reset to |
433 | .B /dev/null, | |
434 | so this is a compatible change. | |
435 | .PP | |
436 | When using the new terminal driver with the LTOSTOP bit set in the local | |
437 | modes, a process is prohibited from writing on its control terminal if it is | |
438 | not in the distinguished process group for that terminal. | |
439 | Processes which are holding or ignoring SIGTTOU signals, which are | |
440 | orphans, or which are in the middle of a | |
441 | .IR vfork (2) | |
442 | are excepted and allowed to produce output. | |
443 | .LP | |
444 | .B "Summary of modes." | |
445 | .LP | |
446 | Unfortunately, due to the evolution of the terminal driver, | |
447 | there are 4 different structures which contain various portions of the | |
448 | driver data. The first of these (\fBsgttyb\fR) | |
449 | contains that part of the information | |
450 | largely common between version 6 and version 7 UNIX systems. | |
451 | The second contains additional control characters added in version 7. | |
452 | The third is a word of local state peculiar to the new terminal driver, | |
453 | and the fourth is another structure of special characters added for the | |
454 | new driver. In the future a single structure may be made available | |
455 | to programs which need to access all this information; most programs | |
456 | need not concern themselves with all this state. | |
457 | .de Ul | |
458 | .ie t \\$1\l'|0\(ul' | |
459 | .el \fI\\$1\fP | |
460 | .. | |
461 | .LP | |
462 | .Ul "Basic modes: sgtty." | |
463 | .PP | |
464 | The basic | |
465 | .IR ioctl s | |
466 | use the structure | |
467 | defined in | |
468 | .IR <sgtty.h> : | |
469 | .PP | |
470 | .ta .5i 1i | |
471 | .nf | |
472 | .ft 3 | |
473 | struct sgttyb { | |
474 | char sg_ispeed; | |
475 | char sg_ospeed; | |
476 | char sg_erase; | |
477 | char sg_kill; | |
478 | short sg_flags; | |
479 | }; | |
480 | .ft R | |
481 | .fi | |
482 | .PP | |
483 | The | |
484 | .I sg_ispeed | |
485 | and | |
486 | .I sg_ospeed | |
487 | fields describe the input and output speeds of the | |
488 | device according to the following table, | |
489 | which corresponds to the DEC DH-11 interface. | |
490 | If other hardware is used, | |
491 | impossible speed changes are ignored. | |
492 | Symbolic values in the table are as defined in | |
493 | .IR <sgtty.h> . | |
494 | .PP | |
495 | .nf | |
496 | .ta \w'B9600 'u +5n | |
497 | B0 0 (hang up dataphone) | |
498 | B50 1 50 baud | |
499 | B75 2 75 baud | |
500 | B110 3 110 baud | |
501 | B134 4 134.5 baud | |
502 | B150 5 150 baud | |
503 | B200 6 200 baud | |
504 | B300 7 300 baud | |
505 | B600 8 600 baud | |
506 | B1200 9 1200 baud | |
507 | B1800 10 1800 baud | |
508 | B2400 11 2400 baud | |
509 | B4800 12 4800 baud | |
510 | B9600 13 9600 baud | |
511 | EXTA 14 External A | |
512 | EXTB 15 External B | |
513 | .fi | |
514 | .DT | |
515 | .PP | |
516 | In the current configuration, | |
517 | only 110, 150, 300 and 1200 baud are really supported on dial-up lines. | |
518 | Code conversion and line control required for | |
519 | IBM 2741's (134.5 baud) | |
520 | must be implemented by the user's | |
521 | program. | |
522 | The half-duplex line discipline | |
523 | required for the 202 dataset (1200 baud) | |
524 | is not supplied; full-duplex 212 datasets work fine. | |
525 | .PP | |
526 | The | |
527 | .I sg_erase | |
528 | and | |
529 | .I sg_kill | |
530 | fields of the argument structure | |
531 | specify the erase and kill characters respectively. | |
532 | (Defaults are # and @.) | |
533 | .PP | |
534 | The | |
535 | .I sg_flags | |
536 | field of the argument structure | |
537 | contains several bits that determine the | |
538 | system's treatment of the terminal: | |
539 | .PP | |
540 | .ta \w'ALLDELAY 'u +\w'0100000 'u | |
541 | .nf | |
542 | ALLDELAY 0177400 Delay algorithm selection | |
543 | BSDELAY 0100000 Select backspace delays (not implemented): | |
544 | BS0 0 | |
545 | BS1 0100000 | |
546 | VTDELAY 0040000 Select form-feed and vertical-tab delays: | |
547 | FF0 0 | |
548 | FF1 0100000 | |
549 | CRDELAY 0030000 Select carriage-return delays: | |
550 | CR0 0 | |
551 | CR1 0010000 | |
552 | CR2 0020000 | |
553 | CR3 0030000 | |
554 | TBDELAY 0006000 Select tab delays: | |
555 | TAB0 0 | |
556 | TAB1 0001000 | |
557 | TAB2 0004000 | |
558 | XTABS 0006000 | |
559 | NLDELAY 0001400 Select new-line delays: | |
560 | NL0 0 | |
561 | NL1 0000400 | |
562 | NL2 0001000 | |
563 | NL3 0001400 | |
564 | EVENP 0000200 Even parity allowed on input (most terminals) | |
565 | ODDP 0000100 Odd parity allowed on input | |
566 | RAW 0000040 Raw mode: wake up on all characters, 8-bit interface | |
567 | CRMOD 0000020 Map CR into LF; echo LF or CR as CR-LF | |
568 | ECHO 0000010 Echo (full duplex) | |
569 | LCASE 0000004 Map upper case to lower on input | |
570 | CBREAK 0000002 Return each character as soon as typed | |
571 | TANDEM 0000001 Automatic flow control | |
572 | .DT | |
573 | .fi | |
574 | .PP | |
575 | The delay bits specify how long | |
576 | transmission stops to allow for mechanical or other movement | |
577 | when certain characters are sent to the terminal. | |
578 | In all cases a value of 0 indicates no delay. | |
579 | .PP | |
580 | Backspace delays are currently ignored but might | |
581 | be used for Terminet 300's. | |
582 | .PP | |
583 | If a form-feed/vertical tab delay is specified, | |
584 | it lasts for about 2 seconds. | |
585 | .PP | |
586 | Carriage-return delay type 1 lasts about .08 seconds | |
587 | and is suitable for the Terminet 300. | |
588 | Delay type 2 lasts about .16 seconds and is suitable | |
589 | for the VT05 and the TI 700. | |
590 | Delay type 3 is suitable for the concept-100 and pads lines | |
591 | to be at least 9 characters at 9600 baud. | |
592 | .PP | |
593 | New-line delay type 1 is dependent on the current column | |
594 | and is tuned for Teletype model 37's. | |
595 | Type 2 is useful for the VT05 and is about .10 seconds. | |
596 | Type 3 is unimplemented and is 0. | |
597 | .PP | |
598 | Tab delay type 1 is dependent on the amount of movement | |
599 | and is tuned to the Teletype model | |
600 | 37. | |
601 | Type 3, called XTABS, | |
602 | is not a delay at all but causes tabs to be replaced | |
603 | by the appropriate number of spaces on output. | |
604 | .PP | |
605 | Input characters with the wrong parity, as determined by bits 200 and | |
606 | 100, are ignored in cooked and CBREAK mode. | |
607 | .PP | |
608 | RAW | |
609 | disables all processing save output flushing with LFLUSHO; | |
610 | full 8 bits of input are given as soon as | |
611 | it is available; all 8 bits are passed on output. | |
612 | A break condition in the input is reported as a null character. | |
613 | If the input queue overflows in raw mode it is discarded; this applies | |
614 | to both new and old drivers. | |
615 | .PP | |
616 | CRMOD causes input carriage returns to be turned into | |
617 | new-lines; | |
618 | input of either CR or LF causes LF-CR both to | |
619 | be echoed | |
620 | (for terminals with a new-line function). | |
621 | .PP | |
622 | CBREAK is a sort of half-cooked (rare?) mode. | |
623 | Programs can read each character as soon as typed, instead | |
624 | of waiting for a full line; | |
625 | all processing is done except the input editing: | |
626 | character and word erase and line kill, input reprint, | |
627 | and the special treatment of \e or EOT are disabled. | |
628 | .PP | |
629 | TANDEM mode causes the system to produce | |
630 | a stop character (default ^S) whenever the input | |
631 | queue is in danger of overflowing, and a start character | |
632 | (default ^Q) | |
633 | when the input queue has drained sufficiently. | |
634 | It is useful for flow control when the `terminal' | |
635 | is really another computer which understands the conventions. | |
636 | .LP | |
637 | .Ul "Basic ioctls" | |
638 | .PP | |
639 | In addition to the TIOCSETD and TIOCGETD disciplines discussed | |
640 | in \fBLine disciplines\fR above, | |
641 | a large number of other | |
642 | .IR ioctl (2) | |
643 | calls apply to terminals, and have the general form: | |
644 | .PP | |
645 | .B #include <sgtty.h> | |
646 | .PP | |
647 | .B ioctl(fildes, code, arg) | |
648 | .br | |
649 | .B struct sgttyb *arg; | |
650 | .PP | |
651 | The applicable codes are: | |
652 | .IP TIOCGETP 15 | |
653 | Fetch the basic parameters associated with the terminal, and store | |
654 | in the pointed-to \fIsgttyb\fR structure. | |
655 | .IP TIOCSETP | |
656 | Set the parameters according to the pointed-to \fIsgttyb\fR structure. | |
657 | The interface delays until output is quiescent, | |
658 | then throws away any unread characters, | |
659 | before changing the modes. | |
660 | .IP TIOCSETN | |
661 | Set the parameters like TIOCSETP but do not delay or flush input. | |
662 | Input is not preserved, however, when changing to or from RAW. | |
663 | .PP | |
664 | With the following codes the | |
665 | .I arg | |
666 | is ignored. | |
667 | .IP TIOCEXCL 15 | |
668 | Set \*(lqexclusive-use\*(rq mode: | |
669 | no further opens are permitted until the file has been closed. | |
670 | .IP TIOCNXCL | |
671 | Turn off \*(lqexclusive-use\*(rq mode. | |
672 | .IP TIOCHPCL | |
673 | When the file is closed for the last time, | |
674 | hang up the terminal. | |
675 | This is useful when the line is associated | |
676 | with an ACU used to place outgoing calls. | |
677 | .IP TIOCFLUSH | |
678 | All characters waiting in input or output queues are flushed. | |
679 | .LP | |
680 | The remaining calls are not available in vanilla version 7 UNIX. | |
681 | In cases where arguments are required, they are described; \fIarg\fR | |
682 | should otherwise be given as 0. | |
683 | .IP TIOCSTI 15 | |
684 | the argument is the address of a character which the system | |
685 | pretends was typed on the terminal. | |
686 | .IP TIOCSBRK 15 | |
687 | the break bit is set in the terminal. | |
688 | .IP TIOCCBRK | |
689 | the break bit is cleared. | |
690 | .IP TIOCSDTR | |
691 | data terminal ready is set. | |
692 | .IP TIOCCDTR | |
693 | data terminal ready is cleared. | |
694 | .IP TIOCGPGRP | |
695 | arg is the address of a word into which is placed the process group | |
696 | number of the control terminal. | |
697 | .IP TIOCSPGRP | |
698 | arg is a word (typically a process id) which becomes the process | |
699 | group for the control terminal. | |
700 | .IP FIONREAD | |
701 | returns in the long integer whose address is arg the number | |
702 | of immediately readable characters from the argument unit. | |
703 | This works for files, pipes, and terminals, but not (yet) | |
704 | for multiplexed channels. | |
705 | .LP | |
706 | .Ul Tchars | |
707 | .PP | |
708 | The second structure associated with each terminal specifies | |
709 | characters that are special in both the old and new terminal interfaces: | |
710 | The following structure is defined in | |
711 | .IR <sys/ioctl.h> , | |
712 | which is automatically included in | |
713 | .IR <sgtty.h> : | |
714 | .PP | |
715 | .nf | |
716 | .ft 3 | |
717 | .ta .5i 1i 2i | |
718 | struct tchars { | |
719 | char t_intrc; /* interrupt */ | |
720 | char t_quitc; /* quit */ | |
721 | char t_startc; /* start output */ | |
722 | char t_stopc; /* stop output */ | |
723 | char t_eofc; /* end-of-file */ | |
724 | char t_brkc; /* input delimiter (like nl) */ | |
725 | }; | |
726 | .DT | |
727 | .fi | |
728 | .ft R | |
729 | .PP | |
730 | The default values for these characters are | |
731 | ^?, ^\e\|, ^Q, ^S, ^D, and \-1. | |
732 | A character value of \-1 | |
733 | eliminates the effect of that character. | |
734 | The | |
735 | .I t_brkc | |
736 | character, by default \-1, | |
737 | acts like a new-line in that it terminates a `line,' | |
738 | is echoed, and is passed to the program. | |
739 | The `stop' and `start' characters may be the same, | |
740 | to produce a toggle effect. | |
741 | It is probably counterproductive to make | |
742 | other special characters (including erase and kill) | |
743 | identical. | |
744 | The applicable ioctl calls are: | |
745 | .IP TIOCGETC 12 | |
746 | Get the special characters and put them in the specified structure. | |
747 | .IP TIOCSETC 12 | |
748 | Set the special characters to those given in the structure. | |
749 | .LP | |
750 | .Ul "Local mode" | |
751 | .PP | |
752 | The third structure associated with each terminal is a local mode word; | |
753 | except for the LNOHANG bit, this word is interpreted only when the new | |
754 | driver is in use. | |
755 | The bits of the local mode word are: | |
756 | .sp | |
757 | .nf | |
758 | LCRTBS 000001 Backspace on erase rather than echoing erase | |
759 | LPRTERA 000002 Printing terminal erase mode | |
760 | LCRTERA 000004 Erase character echoes as backspace-space-backspace | |
761 | LTILDE 000010 Convert ~ to \` on output (for Hazeltine terminals) | |
762 | LMDMBUF 000020 Stop/start output when carrier drops | |
763 | LLITOUT 000040 Suppress output translations | |
764 | LTOSTOP 000100 Send SIGTTOU for background output | |
765 | LFLUSHO 000200 Output is being flushed | |
766 | LNOHANG 000400 Don't send hangup when carrier drops | |
767 | LETXACK 001000 Diablo style buffer hacking (unimplemented) | |
768 | LCRTKIL 002000 BS-space-BS erase entire line on line kill | |
769 | LINTRUP 004000 Generate interrupt SIGTINT when input ready to read | |
770 | LCTLECH 010000 Echo input control chars as ^X, delete as ^? | |
771 | LPENDIN 020000 Retype pending input at next read or input character | |
772 | LDECCTQ 040000 Only ^Q restarts output after ^S, like DEC systems | |
773 | .fi | |
774 | .sp | |
775 | The applicable | |
776 | .I ioctl | |
777 | functions are: | |
778 | .IP TIOCLBIS 15 | |
779 | arg is the address of a | |
780 | mask which is the bits to be set in the local mode word. | |
781 | .IP TIOCLBIC | |
782 | arg is the address of a mask of bits to be cleared in the local mode word. | |
783 | .IP TIOCLSET | |
784 | arg is the address of a mask to be placed in the local mode word. | |
785 | .IP TIOCLGET | |
786 | arg is the address of a word into which the current mask is placed. | |
787 | .LP | |
788 | .Ul "Local special chars" | |
789 | .PP | |
790 | The | |
791 | final structure associated with each terminal is the | |
792 | .I ltchars | |
793 | structure which defines interrupt characters | |
794 | for the new terminal driver. | |
795 | Its structure is: | |
796 | .nf | |
797 | .sp | |
798 | .ta .5i 1i 2i | |
799 | .ft B | |
800 | struct ltchars { | |
801 | char t_suspc; /* stop process signal */ | |
9313e78d | 802 | char t_dsuspc; /* delayed stop process signal */ |
02d430a1 KM |
803 | char t_rprntc; /* reprint line */ |
804 | char t_flushc; /* flush output (toggles) */ | |
9313e78d | 805 | char t_werasc; /* word erase */ |
02d430a1 KM |
806 | char t_lnextc; /* literal next character */ |
807 | }; | |
808 | .ft R | |
809 | .fi | |
810 | .sp | |
811 | The default values for these characters are ^Z, ^Y, ^R, ^O, ^W, and ^V. | |
812 | A value of \-1 disables the character. | |
813 | .PP | |
814 | The applicable \fIioctl\fR functions are: | |
815 | .IP TIOCSLTC 12 | |
816 | args is the address of a | |
817 | .I ltchars | |
818 | structure which defines the new local special characters. | |
819 | .IP TIOCGLTC 12 | |
820 | args is the address of a | |
821 | .I ltchars | |
822 | structure into which is placed the current set of local special characters. | |
823 | .SH FILES | |
824 | /dev/tty | |
825 | .br | |
826 | /dev/tty* | |
827 | .br | |
828 | /dev/console | |
829 | .SH SEE ALSO | |
9313e78d KM |
830 | csh(1), |
831 | stty(1), | |
832 | ioctl(2), | |
833 | sigvec(2), | |
834 | stty(3C), | |
835 | getty(8), | |
836 | init(8) | |
02d430a1 KM |
837 | .SH BUGS |
838 | Half-duplex terminals are not supported. |