|
|
1.1 ! root 1: ! 2: ! 3: termio Device Driver termio ! 4: ! 5: ! 6: ! 7: ! 8: General terminal interface ! 9: ! 10: ! 11: Under the COHERENT system, all asynchronous ports use the same ! 12: interface, no matter what hardware is involved. The remainder of ! 13: this section discusses the common features of this interface. ! 14: ! 15: When a terminal file is opened, it normally causes the process to ! 16: wait until a connection is established. In practice, users' ! 17: programs seldom open these files; they are opened by the program ! 18: getty and become a user's standard input, output, and error ! 19: files. The very first terminal file opened by the process group ! 20: leader of a terminal file not already associated with a process ! 21: group becomes the control terminal for that process group. The ! 22: control terminal plays a special role in handling quit and inter- ! 23: rupt signals, as discussed below. The control terminal is in- ! 24: herited by a child process during a call to fork. A process can ! 25: break this association by changing its process group using ! 26: setpgrp. ! 27: ! 28: A terminal associated with one of these files ordinarily operates ! 29: in full-duplex mode. Characters can be typed at any time, even ! 30: while output is occurring, and are only lost when the system's ! 31: input buffers become completely full, which is rare, or when the ! 32: user has accumulated the maximum allowed number of input charac- ! 33: ters that have not yet been read by some program. Currently, ! 34: this limit is 256 characters. When the input limit is reached, ! 35: the sytems throws away all the saved characters without notice. ! 36: ! 37: Normally, terminal input is processed in units of lines. A line ! 38: is delimited by a newline character (ASCII LF), an end-of-file ! 39: character (ASCII EOT), or an end-of-line character. This means ! 40: that a program attempting to read will be suspended until an en- ! 41: tire line has been typed. Also, no matter how many characters ! 42: are requested in the read call, at most one line will be ! 43: returned. It is not, however, necessary to read a whole line at ! 44: once; any number of characters may be requested in a read, even ! 45: one, without losing information. ! 46: ! 47: During input, the system normally processes erase and kill ! 48: characters. By default, the backspace character erases the last ! 49: character typed, except that it will not erase beyond the begin- ! 50: ning of the line. By default, the <ccttrrll-UU> calls (deletes) the ! 51: entire input line, and optionally outputs a newline character. ! 52: Both these characters operate on a keystroke-by-keystroke basis, ! 53: independently of any backspacing or tabbing which may have been ! 54: done. Both the erase and kill characters may be entered liter- ! 55: ally by preceding them with the escape character (\). In this ! 56: case, the escape character is not read. You may change the erase ! 57: and kill characters. ! 58: ! 59: Certain characters have special functions on input. These ! 60: functions and their default character values are summarized as ! 61: follows: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66: ! 67: ! 68: ! 69: termio Device Driver termio ! 70: ! 71: ! 72: ! 73: ! 74: IINNTTRR (<ccttrrll-CC> or ASCII ETX) generates an interrupt signal ! 75: that is sent to all processes with the associated con- ! 76: trol terminal. Normally, each such process is forced ! 77: to terminate, but arrangements may be made either to ! 78: ignore the signal or to receive a trap to an agreed- ! 79: upon location; see the Lexicon entry for signal. ! 80: ! 81: QQUUIITT (Control-\ or ASCII ES) generates a quit signal. Its ! 82: treatment is identical to that of the interrupt signal ! 83: except that, unless a receiving process has made other ! 84: arrangements, it will not only be terminated but a core ! 85: image file (called ccoorree) will be created in the current ! 86: working directory. ! 87: ! 88: EERRAASSEE (<bbaacckkssppaaccee> or ASCII BS) erases the preceding charac- ! 89: ter. It will not erase beyond the start of a line, as ! 90: delimited by a newline, EOF, or EOL character. ! 91: ! 92: KKIILLLL (<ccttrrll-UU> or ASCII NAK) deletes the entire line, as ! 93: delimited by a newline, EOF, or EOL character. ! 94: ! 95: EEOOFF (<ccttrrll-DD> or ASCII EOT) generates an end-of-file ! 96: character from a terminal. When received, all the ! 97: characters waiting to be read are immediately passed to ! 98: the program without waiting for a newline, and the EOF ! 99: is discarded. Thus, if no characters are waiting, ! 100: which is to say the EOF occurred at the beginning of a ! 101: line. zero characters will be passed back, which is ! 102: the standard end-of-file indication. ! 103: ! 104: NNLL (ASCII LF) is the normal line delimiter. It cannot be ! 105: changed or escaped. ! 106: ! 107: EEOOLL (ASCII LF) is an additional line delimiter, line NL. ! 108: It is not normally used. ! 109: ! 110: SSTTOOPP (<ccttrrll-SS> or ASCII DC3) can be used to suspend output. ! 111: It is useful with CRT terminals to prevent output from ! 112: disappearing before it can be read. While output is ! 113: suspended, STOP characters are ignored and not read. ! 114: ! 115: SSTTAARRTT (<ccttrrll-QQ> or ASCII DC1) resumes output that has been ! 116: suspended by a STOP character. While output is not ! 117: suspended, START characters are ignored and not read. ! 118: The start/stop characters can not be changed or es- ! 119: caped. ! 120: ! 121: The character values for INTR, QUIT, ERASE, KILL, EOF, and EOL ! 122: may be changed. to suit individual tastes. The ERASE, KILL, and ! 123: EOF character may be escaped by a preceding \ character, in which ! 124: case the system ignores its special meaning. ! 125: ! 126: When the carrier signal from the data-set drops, a hangup signal ! 127: is sent to all processes that have this terminal as the control ! 128: ! 129: ! 130: COHERENT Lexicon Page 2 ! 131: ! 132: ! 133: ! 134: ! 135: termio Device Driver termio ! 136: ! 137: ! 138: ! 139: terminal. Unless other arrangements have been made, this signal ! 140: causes the process to terminate. If the hangup signal is ig- ! 141: nored, any subsequent read returns with an end-of-file indica- ! 142: tion. Thus programs that read a terminal and test for end-of- ! 143: file can terminate appropriately when hung up on. ! 144: ! 145: When one or more characters are written, they are transmitted to ! 146: the terminal as soon as previously written characters have ! 147: finished typing. Input characters are echoed by putting them ! 148: into the output queue as they arrive. If a process produces ! 149: characters more rapidly than they can be printed, it will be ! 150: suspended when its output queue exceeds some limit. When the ! 151: queue has drained down to some threshold, the program resumes. ! 152: ! 153: Several calls to ioctl apply to terminal files. The primary ! 154: calls use the following structure, defined in <tteerrmmiioo.hh>: ! 155: ! 156: ! 157: #define NCC 8 ! 158: struct termio { ! 159: unsigned short c_iflag; /* input modes */ ! 160: unsigned short c_oflag; /* output modes */ ! 161: unsigned short c_cflag; /* control modes */ ! 162: unsigned short c_lflag; /* local modes */ ! 163: char c_line; /* line discipline */ ! 164: unsigned char c_cc[NCC]; /* control chars */ ! 165: }; ! 166: ! 167: ! 168: The special control characters are defined by the array c_cc. ! 169: The relative positions and initial values for each function are ! 170: as follows: ! 171: ! 172: ! 173: 0 INTR ^C ! 174: 1 QUIT ^\ ! 175: 2 ERASE \b ! 176: 3 KILL ^U ! 177: 4 EOF ^D ! 178: 5 EOL \n ! 179: 6 reserved ! 180: 7 reserved ! 181: ! 182: ! 183: The field c_iflag describes the basic terminal input control: ! 184: ! 185: ! 186: IGNBRK 0000001 Ignore break condition. ! 187: BRKINT 0000002 Signal interrupt on break. ! 188: IGNPAR 0000004 Ignore characters with parity errors. ! 189: PARMRK 0000010 Mark parity errors. ! 190: INPCK 0000020 Enable input parity check. ! 191: ISTRIP 0000040 Strip character. ! 192: INLCR 0000100 Map NL to CR on input. ! 193: IGNCR 0000200 Ignore CR. ! 194: ! 195: ! 196: COHERENT Lexicon Page 3 ! 197: ! 198: ! 199: ! 200: ! 201: termio Device Driver termio ! 202: ! 203: ! 204: ! 205: ICRNL 0000400 Map CR to NL on input. ! 206: IUCLC 0001000 Map upper-case to lower-case on input. ! 207: IXON 0002000 Enable start/stop output control. ! 208: IXANY 0004000 Enable any character to restart output. ! 209: IXOFF 0010000 Enable start/stop input control. ! 210: ! 211: ! 212: If IGNBRK is set, the break condition (a character-framing error ! 213: with data all zeros) is ignored, that is, not put on the input ! 214: queue and therefore not read by any process. Otherwise, if ! 215: BRKINT is set, the break condition generates an interrupt signal ! 216: and flushes both the input and output queues. If IGNPAR is set, ! 217: characters with other framing and parity errors are ignored. ! 218: ! 219: If PARMRK is set, a character with a framing or parity error ! 220: which is not ignored is read as the three character sequence ! 221: 0377, 0, X, where X is the data of the character received in er- ! 222: ror. To avoid ambiguity in this case, if ISTRIP is not set, a ! 223: valid character of 0377 is read as 0377, 0377. If PARMRK is not ! 224: set, a framing or parity error which is not ignored is read as ! 225: the character NUL. ! 226: ! 227: If INPCK is set, input parity checking is enabled. If INPCK is ! 228: not set, input parity checking is disabled. This allows output ! 229: parity generation without input parity errors. ! 230: ! 231: If ISTRIP is set, valid input characters are stripped to 7-bits ! 232: before being processed; otherwise, all eight bits are processed. ! 233: ! 234: If INLCR is set, a received NL character is translated into a CR ! 235: character. If IGNCR is set, a received CR character is ignored ! 236: (not read). Otherwise if ICRNL is set, a received CR character ! 237: is translated into a NL character. ! 238: ! 239: If IUCLC is set, a received upper-case alphabetic character is ! 240: translated into the corresponding lower-case character. ! 241: ! 242: If IXON is set, start/stop output control is enabled. A received ! 243: STOP character will suspend output and a received START character ! 244: will restart output. All start/stop characters are ignored and ! 245: not read. If IXANY is set, any input character will restart out- ! 246: put which has been suspended. ! 247: ! 248: IF IXOFF is set, the system will transmit START/STOP characters ! 249: when the input queue is nearly empty/full. ! 250: ! 251: The initial input control value is all bits clear. ! 252: ! 253: The field c_oflag field specifies the system treatment of output: ! 254: ! 255: OPOST 0000001 Postprocess output. ! 256: OLCUC 0000002 Map lower case to upper on output. ! 257: ONLCR 0000004 Map NL to CR-NL on output. ! 258: OCRNL 0000010 Map CR to NL on output. ! 259: ONOCR 0000020 No CR output at column 0. ! 260: ! 261: ! 262: COHERENT Lexicon Page 4 ! 263: ! 264: ! 265: ! 266: ! 267: termio Device Driver termio ! 268: ! 269: ! 270: ! 271: ONLRET 0000040 NL performs CR function. ! 272: OFILL 0000100 Use fill characters for delay. ! 273: OFDEL 0000200 Fill is DEL, else NUL. ! 274: NLDLY 0000400 Select new-line delays: ! 275: NL0 0 ! 276: NL1 0000400 ! 277: CRDLY 0003000 Select carriage-return delays: ! 278: CR0 0 ! 279: CR1 0001000 ! 280: CR2 0002000 ! 281: CR3 0003000 ! 282: TABDLY 0014000 Select horizontal-tab delays: ! 283: TAB0 0 ! 284: TAB1 0004000 ! 285: TAB2 0010000 ! 286: TAB3 0014000 Expand tabs to spaces. ! 287: BSDLY 0020000 Select backspace delays: ! 288: BS0 0 ! 289: BS1 0020000 ! 290: VTDLY 0040000 Select vertical-tab delays: ! 291: VT0 0 ! 292: VT1 0040000 ! 293: FFDLY 0100000 Select form-feed delays: ! 294: FF0 0 ! 295: FF1 0100000 ! 296: ! 297: If OPOST is set, output characters are post-processed as in- ! 298: dicated by the remaining flags; otherwise, characters are trans- ! 299: mitted without change. ! 300: ! 301: If OLCUC is set, a lower-case alphabetic character is transmitted ! 302: as the corresponding upper-case character. This function is of- ! 303: ten used with IUCLC. ! 304: ! 305: If ONLCR is set, the NL character is transmitted as the CR-NL ! 306: character pair. If OCRNL is set, the CR character is transmitted ! 307: as the NL character. If ONOCR is set, no CR character is trans- ! 308: mitted when at column 0 (first position). If ONLRET is set, the ! 309: NL character is assumed to do the carriage-return function; the ! 310: column pointer is set to 0 and the delays specified for CR used. ! 311: Otherwise, the NL character is assumed to do just the line-feed ! 312: function; the column pointer remains unchanged. The column ! 313: pointer is also set to 0 if the CR character is actually trans- ! 314: mitted. ! 315: ! 316: The delay bits specify how long transmission stops to allow for ! 317: mechanical or other movement when certain characters are sent to ! 318: the terminal. In all cases, a value of 0 indicates no delay. If ! 319: OFILL is set, fill characters are transmitted for delay instead ! 320: of a timed delay. This is useful for high baud-rate terminals ! 321: that need only a minimal delay. If OFDEL is set, the fill ! 322: character is DEL; otherwise, it is NUL. ! 323: ! 324: If a form-feed or vertical-tab delay is specified, it lasts for ! 325: about two seconds. ! 326: ! 327: ! 328: COHERENT Lexicon Page 5 ! 329: ! 330: ! 331: ! 332: ! 333: termio Device Driver termio ! 334: ! 335: ! 336: ! 337: ! 338: Newline delay lasts about 0.10 seconds. If ONLRET is set, the ! 339: carriage-return delays are used instead of the newline delays. ! 340: If OFILL is set, two fill characters are transmitted. ! 341: ! 342: Carriage-return delay type 1 is dependent on the current column ! 343: position, type 2 is about 0.10 seconds, and type 3 is about 0.15 ! 344: seconds. If OFILL is set, delay type 1 transmits two fill ! 345: characters, and type 2 four fill characters. ! 346: ! 347: Horizontal-tab delay type 1 depends on the current column posi- ! 348: tion. Type 2 is about 0.10 seconds. Type 3 specifies that tabs ! 349: are to be expanded into spaces. If OFILL is set, two fill ! 350: characters are transmitted for any delay. ! 351: ! 352: Backspace delay lasts about 0.05 seconds. If OFILL is set, one ! 353: fill character is transmitted. ! 354: ! 355: The actual delays depend on line speed and system load. ! 356: ! 357: The initial output control value is all bits clear. ! 358: ! 359: The field c_cflag describes the hardware control of the terminal, ! 360: as follows: ! 361: ! 362: CBAUD 0000017 Baud rate: ! 363: B0 0 Hang up ! 364: B50 0000001 50 baud ! 365: B75 0000002 75 baud ! 366: B110 0000003 110 baud ! 367: B134 0000004 134.5 baud ! 368: B150 0000005 150 baud ! 369: B200 0000006 200 baud ! 370: B300 0000007 300 baud ! 371: B600 0000010 600 baud ! 372: B1200 0000011 1200 baud ! 373: B1800 0000012 1800 baud ! 374: B2400 0000013 2400 baud ! 375: B4800 0000014 4800 baud ! 376: B9600 0000015 9600 baud ! 377: B19200 0000016 19200 baud ! 378: B38400 0000017 38400 baud ! 379: CSIZE 0000060 Character size: ! 380: CS5 0 5 bits ! 381: CS6 0000020 6 bits ! 382: CS7 0000040 7 bits ! 383: CS8 0000060 8 bits ! 384: CSTOPB 0000100 Send two stop bits, else one ! 385: CREAD 0000200 Enable receiver ! 386: PARENB 0000400 Parity enable ! 387: PARODD 0001000 Odd parity, else even ! 388: HUPCL 0002000 Hang up on last close ! 389: CLOCAL 0004000 Local line, else dial-up ! 390: ! 391: ! 392: ! 393: ! 394: COHERENT Lexicon Page 6 ! 395: ! 396: ! 397: ! 398: ! 399: termio Device Driver termio ! 400: ! 401: ! 402: ! 403: The CBAUD bits specify the baud rate. The zero baud rate, B0, is ! 404: used to hang up the connection. If B0 is specified, the data- ! 405: terminal-ready signal is not asserted. Normally, this discon- ! 406: nects the line. For any particular hardware, the system ignores ! 407: impossible changes to the speed. ! 408: ! 409: The CSIZE bits specify the character size in bits for both ! 410: transmission and reception. This size does not include the ! 411: parity bit, if any. If CSTOPB is set, two stop bits are used; ! 412: otherwise, one stop bit. For example, at 110 baud, two stop bits ! 413: are required. ! 414: ! 415: If PARENB is set, parity generation and detection is enabled and ! 416: a parity bit is added to each character. If parity is enabled, ! 417: the PARODD flag specifies odd parity if set; otherwise, even ! 418: parity is used. ! 419: ! 420: If CREAD is set, the receiver is enabled. Otherwise, no charac- ! 421: ters will be received. ! 422: ! 423: If HUPCL is set, COHERENT disconnects the line when the last ! 424: process with the line open closes the line or terminates; that ! 425: is, the data-terminal-ready signal is not asserted. ! 426: ! 427: If CLOCAL is set, the system assumes that the line to be a local, ! 428: direct connection with no modem control. Otherwise, it assumes ! 429: modem control. ! 430: ! 431: The initial hardware control value after open is B300, CS8, ! 432: CREAD, HUPCL. ! 433: ! 434: The line discipline uses the field c_lflag to control terminal ! 435: functions. The basic line discipline (0) provides the following: ! 436: ! 437: ! 438: ISIG 0000001 Enable signals. ! 439: ICANON 0000002 Canonical input (erase and kill processing). ! 440: XCASE 0000004 Canonical upper/lower presentation. ! 441: ECHO 0000010 Enable echo. ! 442: ECHOE 0000020 Echo erase character as BS-SP-BS. ! 443: ECHOK 0000040 Echo NL after kill character. ! 444: ECHONL 0000100 Echo NL. ! 445: NOFLSH 0000200 Disable flush after interrupt or quit. ! 446: ! 447: ! 448: If ISIG is set, the system checks each input character against ! 449: the special control characters INTR and QUIT. If an input ! 450: character matches one of these control characters, the system ex- ! 451: ecutes the function associated with that character. If ISIG is ! 452: not set, the system performs no checking; thus, these special in- ! 453: put functions are possible only if ISIG is set. You can disable ! 454: these functions individually by changing the value of the control ! 455: character to an unlikely or impossible value (e.g. 0377). ! 456: ! 457: ! 458: ! 459: ! 460: COHERENT Lexicon Page 7 ! 461: ! 462: ! 463: ! 464: ! 465: termio Device Driver termio ! 466: ! 467: ! 468: ! 469: If ICANON is set, the system enables canonical processing. This ! 470: enables the erase and kill edit functions, and limits the as- ! 471: sembly of input characters into lines delimited by NL, EOF, and ! 472: EOL. If ICANON is not set, read requests are satisfied directly ! 473: from the input queue. A read will not be satisfied until at ! 474: least MIN characters have been received or the timeout value TIME ! 475: has expired. This allows the system to read efficiently fast ! 476: bursts of input while still allowing single-character input. The ! 477: MIN and TIME values are stored in the position for the EOF and ! 478: EOL characters, respectively. The time value represents tenths ! 479: of seconds. ! 480: ! 481: If XCASE is set, and if ICANON is set, an upper-case letter is ! 482: accepted on input by preceding it with a \ character, and is out- ! 483: put preceded by a \ character. In this mode, the following es- ! 484: cape sequences are generated on output and accepted on input: ! 485: ! 486: ! 487: _F_o_r: _U_s_e: ! 488: ! 489: ` \' ! 490: | \! ! 491: ~ \^ ! 492: { \( ! 493: } \) ! 494: \ \\ ! 495: ! 496: ! 497: For example, AA is input as \aa, \nn as \\nn, and \NN as \\\nn. ! 498: ! 499: If ECHO is set, characters are echoed as received. ! 500: ! 501: When ICANON is set, the following echo functions are possible: If ! 502: ECHO and ECHOE are set, the erase character is echoed as ASCII BS ! 503: SP BS, which clears the last character from the screen. If ECHOE ! 504: is set and EHO is not set, the erase character is echoed as ASCII ! 505: SP BS. If ECHOK is set, the NL character is echoed after the ! 506: kill character to emphasize that the line will be deleted. Note ! 507: that an escape character preceding the erase or kill character ! 508: removes any special function. If ECHONL is set, the NL character ! 509: is echoed even if ECHO is not set. This is useful for terminals ! 510: set to local echo (``half duplex''). Unless escaped, the EOF ! 511: character is not echoed. Because EOT is the default EOF charac- ! 512: ter, this prevents terminals that respond to EOT from hanging up. ! 513: ! 514: If NOFLSH is set, the normal flush of the input and output queues ! 515: associated with the quit and interrupt characters is not done. ! 516: ! 517: The initial line-discipline control value is all bits clear. ! 518: ! 519: The primary calls to ioctl have the following form: ! 520: ! 521: ! 522: ! 523: ! 524: ! 525: ! 526: COHERENT Lexicon Page 8 ! 527: ! 528: ! 529: ! 530: ! 531: termio Device Driver termio ! 532: ! 533: ! 534: ! 535: ioctl( fildes, command, arg ) ! 536: struct termio *arg; ! 537: ! 538: ! 539: The following commands use this form: ! 540: ! 541: TTCCGGEETTAA Get the parameters associated with the terminal and ! 542: store in the termio structure referenced by arg. ! 543: ! 544: TTCCSSEETTAA Set the parameters associated with the terminal from ! 545: the structure referenced by arg. The change is im- ! 546: mediate. ! 547: ! 548: TTCCSSEETTAAWW Wait for the output to drain before setting the new ! 549: parameters. This form should be used when changing ! 550: parameters that affect output. ! 551: ! 552: TTCCSSEETTAAFF Wait for the output to drain, then flush the input ! 553: queue and set the new parameters. ! 554: ! 555: Additional calls to ioctl have the following form: ! 556: ! 557: ! 558: ioctl( fildes, command, arg ) ! 559: int arg; ! 560: ! 561: ! 562: The following commands use this form: ! 563: ! 564: TTCCSSBBRRKK Wait for the output to drain. If arg is zero, then ! 565: send a break (zero bits for 0.25 seconds). ! 566: ! 567: TTCCXXOONNCC Start/stop control. If arg is zero, suspend output; if ! 568: one, restart suspended output. ! 569: ! 570: TTCCFFLLSSHH If arg is zero, flush the input queue; if one, flush ! 571: the output queue; if two, flush both the input and out- ! 572: put queues. ! 573: ! 574: ***** Files ***** ! 575: ! 576: /dev/tty* ! 577: ! 578: ***** See Also ***** ! 579: ! 580: device drivers, ioctl(), stty, termio.h ! 581: ! 582: ! 583: ! 584: ! 585: ! 586: ! 587: ! 588: ! 589: ! 590: ! 591: ! 592: COHERENT Lexicon Page 9 ! 593: ! 594:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.