


      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



      NAME
           termio - general terminal interface

           TERMIO(7) IS NOT A FILE.  THIS EXPLAINS TERMINAL I/O
           CHARACTERISTICS.

      DESCRIPTION
           When a terminal file is opened, it normally causes the
           process to wait until a connection is established. In
           practice, users' programs seldom open these files; they are
           opened by getty and become a user's standard input, output,
           and error files. The very first terminal file opened by the
           process group leader of a terminal file not already
           associated with a process group becomes the control terminal
           for that process group. The control terminal plays a special
           role in handling quit and interrupt signals, as discussed
           below. The control terminal is inherited by a child process
           during a fork(2).  A process can break this association by
           changing its process group using setpgrp(2).

           A terminal associated with one of these files ordinarily
           operates in full-duplex mode. Characters may be typed at any
           time, even while output is occurring, and are only lost when
           the system's character input buffer reaches 4352 characters,
           which is rare, or when the user has accumulated 4352 input
           characters that have not yet been read by some program.
           When the input limit is reached, the oldest character is
           thrown away without notice.

           Normally, terminal input is processed in units of lines.  A
           line is delimited by a new-line (ASCII LF) character, an
           end-of-file (ASCII EOT) character, or a user-defineable
           end-of-line character. This means that a program attempting
           to read will be suspended until an entire line has been
           typed. Also, no matter how many characters are requested in
           the read call, at most one line will be returned. It is not
           necessary, however, to read a whole line at once; any number
           of characters may be requested in a read, even one, without
           losing information.

           During input, erase and kill processing is normally done. By
           default, control-h erases the last character typed, except
           that it will not erase beyond the beginning of the line. By
           default, control-x kills (deletes) the entire input line.
           Both these characters operate on a key-stroke basis,
           independently of any backspacing or tabbing that may have
           been done. The erase and kill characters may be changed.

           Certain characters have special functions on input:

           INTR    (Rubout or ASCII DEL) generates an interrupt signal
                   which is sent to all processes associated with the



      Page 1                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



                   control terminal. Normally, each such process is
                   forced to terminate, but arrangements may be made
                   either to ignore the signal or to receive a trap to
                   an agreed-upon location; see signal(2).

           QUIT    (Control-| or ASCII FS) generates a quit signal. Its
                   treatment is identical to the interrupt signal
                   except that, unless a receiving process has made
                   other arrangements, it will be placed under control
                   of the debugger.

           ERASE   (Control-h) erases the preceding character. It will
                   not erase beyond the start of a line, as delimited
                   by a NL, EOF, or EOL character.

           KILL    (Control-x) deletes the entire line, as delimited by
                   a NL, EOF, or EOL character.

           EOF     (Control-d or ASCII EOT) may be used to generate an
                   end-of-file from a terminal. When received, all the
                   characters waiting to be read are immediately passed
                   to the program, without waiting for a new-line, and
                   the EOF is processed on the next read request.
                   Thus, if there are no characters waiting, which is
                   to say the EOF occurred at the beginning of a line,
                   zero characters will be passed back, which is the
                   standard end-of-file indication.

           NL      (ASCII LF) is the normal line delimiter. It can not
                   be changed or escaped.

           EOL     (ASCII NUL) is an additional line delimiter, like
                   NL.  It is not normally used.

           STOP    (Control-s or ASCII DC3) can be used to temporarily
                   suspend output. It is useful with CRT terminals to
                   prevent output from disappearing before it can be
                   read.  While output is suspended, STOP characters
                   are ignored and not read.

           START   (Control-q or ASCII DC1) is used to resume output
                   which has been suspended by a STOP character.  While
                   output is not suspended, START characters are
                   ignored and not read. The start/stop characters can
                   not be changed or escaped.

           The character values for INTR, QUIT, ERASE, KILL, EOF, and
           EOL may be changed to suit individual tastes.

           When one or more characters are written, they are
           transmitted to the terminal as soon as previously-written
           characters have finished typing. Input characters are echoed



      Page 2                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



           by putting them in the output queue when input is requested
           by a read on the terminal file. If a process produces
           characters more rapidly than they can be typed, it will be
           suspended when its output queue exceeds some limit. When the
           queue has drained down to some threshold, the program is
           resumed.

           Several ioctl(2) system calls apply to terminal files. The
           primary calls use the following structure, defined in
           <termio.h>:

                #define   NCC   8
                struct termio {
                   int      c_version;   /* termio structure version */
                   int      c_iflag;     /* input modes */
                   int      c_oflag;     /* output modes   */
                   int      c_cflag;     /* control modes */
                   int      c_lflag;     /* line   discipline modes */
                   int      c_line;      /* line   discipline */
                   int      c_numchr;    /* number of control chars following */
                   unsigned char   c_cc[NCC];   /* control chars */
                };

           The special control characters are defined by the array
           c_cc.  The relative positions and initial values for each
           function are as follows:
                0   INTR      DEL
                1   QUIT      FS
                2   ERASE     control-h
                3   KILL      control-x
                4   EOF       EOT
                5   EOL       NUL
                6   JOB       control-z
                7   reserved

           The c_iflag field describes the basic terminal input
           control:

                IGNBRK   0000001   Ignore break condition.
                BRKINT   0000002   Signal interrupt on break.
                IGNPAR   0000004   Ignore characters with parity errors.
                PARMRK   0000010   Mark parity errors.
                INPCK    0000020   Enable input parity check.
                ISTRIP   0000040   Strip character.
                INLCR    0000100   Map NL to CR on input.
                IGNCR    0000200   Ignore CR.
                ICRNL    0000400   Map CR to NL on input.
                IUCLC    0001000   Map upper-case to lower-case on input.
                IXON     0002000   Enable start/stop output control.
                IXANY    0004000   Enable any character to restart output.
                IXOFF    0010000   Enable start/stop input control.




      Page 3                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



           If IGNBRK is set, the break condition (a character framing
           error with data all zeros) is ignored, that is, not put on
           the input queue and therefore not read by any process.
           Otherwise if BRKINT is set, the break condition will
           generate an interrupt signal and flush both the input and
           output queues. If IGNPAR is set, characters with other
           framing and parity errors are ignored.

           If PARMRK is set, a character with a framing or parity error
           which is not ignored is read as the three character
           sequence: 0377, 0, X, where X is the data of the character
           received in error. To avoid ambiguity in this case, if
           ISTRIP is not set, a valid character of 0377 is read as
           0377, 0377. If PARMRK is not set, a framing or parity error
           which is not ignored is read as the character NUL (0).

           If INPCK is set, input parity checking is enabled. If INPCK
           is not set, input parity checking is disabled. This allows
           output parity generation without input parity errors.

           If ISTRIP is set, valid input characters are first stripped
           to 7-bits, otherwise all 8-bits are processed.

           If INLCR is set, a received NL character is translated into
           a CR character. If IGNCR is set, a received CR character is
           ignored (not read). Otherwise if ICRNL is set, a received CR
           character is translated into a NL character.

           If IUCLC is set, a received upper-case alphabetic character
           is translated into the corresponding lower-case character.

           If IXON is set, start/stop output control is enabled. A
           received STOP character will suspend output and a received
           START character will restart output. All start/stop
           characters are ignored and not read.

           If IXANY is set, any input character, will restart output
           which has been suspended. IXANY is NOT implemented.

           If IXOFF is set, the system will transmit START/STOP
           characters when the input queue is nearly empty/full.


           The initial input control value is all bits clear.

           The c_oflag field specifies the system treatment of output:

                OPOST   0000001   Postprocess output.
                OLCUC   0000002   Map lower case to upper on output.
                ONLCR   0000004   Map NL to CR-NL on output.
                OCRNL   0000010   Map CR to NL on output.
                ONOCR   0000020   No CR output at column 0.



      Page 4                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



                ONLRET  0000040   NL performs CR function.
                OFILL   0000100   Use fill characters for delay.
                OFDEL   0000200   Fill is DEL, else NUL.
                NLDLY   0000400   Select new-line delays:
                NL0     0
                NL1     0000400
                CRDLY   0003000   Select carriage-return delays:
                CR0     0
                CR1     0001000
                CR2     0002000
                CR3     0003000
                TABDLY  0014000   Select horizontal-tab delays:
                TAB0    0
                TAB1    0004000
                TAB2    0010000
                TAB3    0014000   Expand tabs to spaces.
                BSDLY   0020000   Select backspace delays:
                BS0     0
                BS1     0020000
                VTDLY   0040000   Select vertical-tab delays:
                VT0     0
                VT1     0040000
                FFDLY   0100000   Select form-feed delays:
                FF0     0
                FF1     0100000

                      ONLY THE FOLLOWING ARE IMPLEMENTED:
                      OPOST, OLCUC, ONLCR, OCRNL, ONLRET, ONOCR, TAB3

           If OPOST is set, output characters are post-processed as
           indicated by the remaining flags, otherwise characters are
           transmitted without change.

           If OLCUC is set, a lower-case alphabetic character is
           transmitted as the corresponding upper-case character. This
           function is often used in conjunction with IUCLC.

           If ONLCR is set, the NL character is transmitted as the CR-
           NL character pair.  If OCRNL is set, the CR character is
           transmitted as the NL character.  If ONOCR is set, no CR
           character is transmitted when at column 0 (first position).

           If ONLRET is set, the NL character is assumed to do the
           carriage-return function; the column pointer will be set to
           0 and the delays specified for CR will be used.  Otherwise
           the NL character is assumed to do just the line-feed
           function; the column pointer will remain unchanged. The
           column pointer is also set to 0 if the CR character is
           actually transmitted.

           Horizontal-tab delay type 3, the only delay bit implemented,
           specifies that tabs are to be expanded into spaces.



      Page 5                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



           The initial output control value is all bits clear.

           The c_cflag field (WHICH IS IGNORED BY THE BULL-SPS9
           DISPLAY) describes the hardware control of the terminal:

                CBAUD       0000037 Baud rate:
                  B75   0000002  75 baud
                  B110  0000003  110 baud
                  B134  0000004  134.5 baud
                  B150  0000005  150 baud
                  B200  0000006  200 baud
                  B300  0000007  300 baud
                  B600  0000010  600 baud
                  B1200 0000011  1200 baud
                  B1800 0000012  1800 baud
                  B2400 0000013  2400 baud
                  B4800 0000014  4800 baud
                  B9600 0000015  9600 baud
                EXTA    0000016  External A
                EXTB    0000017  External B
                B19200  0000020  19200 baud
                CSIZE   0000140  Character size:
                  CS5   0        5 bits
                  CS6   0000040  6 bits
                  CS7   0000100  7 bits
                  CS8   0000140  8 bits
                CSTOPB  0000200   Send two stop bits, else one.
                CREAD   0000400   Enable receiver.
                PARENB  0001000   Parity enable.
                PARODD  0002000   Odd parity, else even.
                HUPCL   0004000   Hang up on last close.
                CLOCAL  0010000   Local line, else dial-up.
                CAUTO   0020000   Enable RS-232 hardware flow-control.

           The CBAUD bits specify the baud rate. For any particular
           hardware, impossible speed changes are ignored.

           The CSIZE bits specify the character size in bits for both
           transmission and reception. This size does not include the
           parity bit, if any. If CSTOPB is set, two stop bits are
           used, otherwise one stop bit. For example, at 110 baud, two
           stops bits are required.

           If PARENB is set, parity generation and detection is enabled
           and a parity bit is added to each character. If parity is
           enabled, the PARODD flag specifies odd parity if set,
           otherwise even parity is used.

           If CREAD is set, the receiver is enabled. Otherwise no
           characters will be received.

           If HUPCL is set, the line will be disconnected when the last



      Page 6                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



           process with the line open closes it or terminates. That is,
           the data-terminal-ready signal will not be asserted.

           If CLOCAL is set, the line is assumed to be a local, direct
           connection with no modem control. Otherwise modem control is
           assumed.

           If CAUTO is set, hardware flow-control for RS-232 terminals
           is enabled.  This feature prevents too-rapid input/output
           with a peripheral device.  If enabled, the RS-232 receiver
           and transmitter are switched on and off by the "carrier
           detect" (DCD) and the "clear to send" (CTS) lines,
           respectively.  No data will be received unless DCD (pin 8)
           is true, and no data will be transmitted until CTS (pin 5)
           is true.

           The initial hardware control value after open is B9600, CS7
           CREAD, PARENB.  CLOCAL.

           The c_lflag field of the argument structure is used by the
           line discipline to control terminal functions. The basic
           line discipline (0) provides the following:

                ISIG    0000001   Enable signals.
                ICANON  0000002   Canonical input (erase and kill processing).
                XCASE   0000004  *Canonical upper/lower presentation.
                ECHO    0000010   Enable echo.
                ECHOE   0000020   Echo erase character as BS-SP-BS.
                ECHOK   0000040   Echo NL after kill character.
                NOFLSH  0000200   Disable flush after interrupt or quit.
                LINTRUP 0000400   Generate signal SIGIO when data is available.

                            * IGNORED BY BULL-SPS9 DISPLAY

           If ISIG is set, each input character is checked against the
           special control characters INTR, JOB, and QUIT.  If an input
           character matches one of these control characters, the
           function associated with that character is performed. If
           ISIG is not set, no checking is done. Thus these special
           input functions are possible only if ISIG is set. These
           functions may be disabled individually by changing the value
           of the control character to an unlikely or impossible value
           (e.g. 0377).

           If ICANON is set, canonical processing is enabled. This
           enables the erase and kill edit functions, and the assembly
           of input characters into lines delimited by NL, EOF, and
           EOL.  If ICANON is not set, read requests are satisfied
           directly from the input queue.  A read will not be satisfied
           until at least MIN characters have been received. This
           allows fast bursts of input to be read efficiently while
           still allowing single character input. The MIN value is



      Page 7                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



           stored in the position for the EOF character. The time value
           represents tenths of seconds.

           If ECHO is set, characters are echoed as received.

           When ICANON is set, the following echo functions are
           possible. If ECHO and ECHOE are set, the erase character is
           echoed as ASCII BS SP BS, which will clear the last
           character from a CRT screen.  If ECHOE is set and ECHO is
           not set, the erase character is echoed as ASCII SP BS.  If
           ECHOK is set, the NL character will be echoed after the kill
           character to emphasize that the line will be deleted,
           otherwise a series of backspace- space- backspace sequences
           are output to cause the line to be erased. Note that an
           escape character preceding the erase or kill character
           removes any special function. Unless escaped, the EOF
           character is not echoed. Because EOT is the default EOF
           character, this prevents terminals that respond to EOT from
           hanging up.

           If NOFLSH is set, the normal flush of the input and output
           queues associated with the quit and interrupt characters
           will not be done.

           The initial line-discipline control value is all bits clear.

           The primary ioctl(2) system calls have the form:

                ioctl (fildes, command, arg)
                struct termio *arg;

           The commands using this form are:

                TCGETA    Get the parameters associated with the
                          terminal and store in the termio structure
                          referenced by arg.

                TCSETA    Set the parameters associated with the
                          terminal from the structure referenced by
                          arg.  The change is immediate.

                TCSETAW   Wait for the output to drain before setting
                          the new parameters.  This form should be used
                          when changing parameters that will affect
                          output.

                TCSETAF   Wait for the output to drain, then flush the
                          input queue and set the new parameters.

           Additional ioctl(2) calls have the form:

                ioctl (fildes, command, arg)



      Page 8                                         (73 A2 02MTA REV1)






      TERMIO(7)                   (UNIX 5.0)                  TERMIO(7)



                int arg;

           The commands using this form are:

                TCXONC    Start/stop control.  If arg is 0, suspend
                          output; if 1, restart suspended output.

                TCFLSH    If arg is 0, flush the input queue; if 1,
                          flush the output queue; if 2, flush both the
                          input and output queues.

      SEE ALSO
           stty(1), ioctl(2).










































      Page 9                                         (73 A2 02MTA REV1)



