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