Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stty(1)

setpgrp(2)

signal(2)

fork(2)

ioctl(2)



  termio(7)                           CLIX                           termio(7)



  NAME

    termio - General terminal interface

  DESCRIPTION

    All asynchronous communications ports use the same general interface,
    regardless of the hardware involved.  The remainder of this section
    discusses the common features of this interface.

    When a terminal file is opened, it normally causes the process to wait
    until a connection is established.  In practice, user programs seldom open
    terminal files; they are opened by getty and become a user's stdin,
    stdout, and stderr files.  The 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
    (discussed below).  The control terminal is inherited by a child process
    during a fork() function.  A process can break this association by
    changing its process group using setpgrp() function.

    A terminal associated with one of these files ordinarily operates in
    full-duplex mode.  Characters may be typed any time, even while output is
    occurring, and are only lost when the system's character input buffers
    become completely full (which is rare) or when the user has accumulated
    the maximum allowed number of input characters that have not yet been read
    by some program.  Currently, this limit is 256 characters.  When the input
    limit is reached, the buffer is flushed and all the saved characters are
    discarded without notice.

    Normally, terminal input is processed in units of lines.  A line is
    delimited by a newline (ASCII LF) character, an end-of-file (ASCII EOT)
    character, or an end-of-line (ASCII EOL) 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.  However, it is not necessary to
    read a whole line at once; any number of characters may be requested in a
    read (even one character) without losing information.

    During input, erase and kill processing is normally performed.  By
    default, the number sign (#) erases the last character typed, except that
    it will not erase beyond the beginning of the line.  By default, the at
    (@) character deletes the entire input line and optionally outputs a
    newline character.  Both characters operate on a key-stroke basis,
    independent from any backspacing or tabbing.  Both the erase and delete
    characters may be entered literally by preceding them with the escape
    character (\).  In this case, the escape character is not read.  The erase
    and delete characters may be changed.

    Certain characters have special functions on input.  These functions and
    their default character values are summarized as follows:



  2/94 - Intergraph Corporation                                              1






  termio(7)                           CLIX                           termio(7)



    INTR    (Rubout or ASCII DEL) Generates an interrupt signal sent to all
            processes with the associated control terminal.  Normally, each
            process is forced to terminate, but arrangements may be made to
            ignore the signal or to receive a trap to an agreed-on location.
            (See signal(2).)

    QUIT    (<Ctrl-L> 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 not only be
            terminated, but a core image file (called core) will be created in
            the current working directory.

    SWTCH   (<Ctrl-Z> or ASCII SUB) Is used by the job control facility, shl,
            to change the current layer to the control layer.

    SUSP    (<Ctrl-Z> or ASCII SUB) Generates a SIGTSTP signal sent to all
            processes with the associated control terminal.  Normally, each
            process is forced to stop, but arrangements may be made either to
            ignore the signal or to receive a trap to an agreed-upon location.
            (See signal(2).)

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

    KILL    (@) Deletes the entire line, as delimited by a NL, EOF, or EOL
            character.

    EOF     (<Ctrl-D> or ASCII EOT) Generates an end-of-file from a terminal.
            When received, all characters waiting to be read are immediately
            passed to the program, without waiting for a newline, and the EOF
            is discarded.  Thus, if no characters are waiting (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 cannot be changed or
            escaped.

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

    EOL2    Is an additional line delimiter.

    STOP    (<Ctrl-S> or ASCII DC3) Temporarily suspend output.  It is used
            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   (<Ctrl-Q> or ASCII DC1) Resumes output that has been suspended by
            a STOP character.  While output is not suspended, START characters
            are ignored and not read.  The start/stop characters cannot be
            changed or escaped.



  2                                              Intergraph Corporation - 2/94






  termio(7)                           CLIX                           termio(7)



    The character values for INTR, QUIT, SWTCH, SUSP, ERASE, KILL, EOF, and
    EOL may be changed.  The ERASE, KILL, and EOF characters may be escaped by
    a preceding backslash (\) character.  In this case, no special function is
    performed.

    When the carrier signal from the data-set drops, a SIGHUP signal is sent
    to all processes that have this terminal as the control terminal.  Unless
    other arrangements have been made, this signal causes the processes to
    terminate.  If the SIGHUP signal is ignored, any subsequent read returns
    with an end-of-file indication.  Thus, programs that read a terminal and
    test for end-of-file can terminate appropriately when hung up on.

    When one or more characters is written, the characters are transmitted to
    the terminal as soon as previously-written characters finish typing.
    Input characters are echoed by putting them in the output queue as they
    arrive.  If a process produces characters more rapidly than they can be
    entered, it will be suspended when its output queue exceeds its limit.
    When the queue has drained to a threshold, the program is resumed.

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

    #define NCC 9
    struct termio {
         unsigned short c_iflag;   /* input modes */
         unsigned short c_oflag;   /* output modes */
         unsigned short c_cflag;   /* control modes */
         unsigned short c_lflag;   /* local modes */
         char           c_line;    /* line discipline */
         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   VINTR
    1   VQUIT
    2   VERASE
    3   VKILL
    4   VEOF
    5   VEOL
    6   VEOL2
    4   VMIN
    5   VTIME
    7   VSWTCH
    8   VSUSP

    The c_iflag field describes the basic terminal input control:

    IGNBRK   0000001   Ignore break condition.
    BRKINT   0000002   Signal interrupt on break.



  2/94 - Intergraph Corporation                                              3






  termio(7)                           CLIX                           termio(7)



    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 uppercase to lowercase on input.
    IXON     0002000   Enable start/stop output control.
    IXANY    0004000   Enable any character to restart output.
    IXOFF    0010000   Enable start/stop input control.

    If IGNBRK is set, the break condition (a character framing error with data
    all zeros) is ignored (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 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 seven bits.
    (The high-order bit is turned to 0.)  Otherwise, all eight 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 uppercase alphabetic character is translated
    into the corresponding lowercase 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 processed and discarded (not placed
    in the input stream).  If IXANY is set, any input character, will restart
    output that has been suspended.

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




  4                                              Intergraph Corporation - 2/94






  termio(7)                           CLIX                           termio(7)



    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 lowercase to uppercase on output.
    ONLCR    0000004   Map NL to CR-NL on output.
    OCRNL    0000010   Map CR to NL on output.
    ONOCR    0000020   No CR is output at column 0.
    ONLRET   0000040   NL performs CR function.
    OFILL    0000100   Use fill characters for delay.
    OFDEL    0000200   Fill is DEL, else NUL.
    NLDLY    0000400   Select newline delays:
    NL0      0000000
    NL1      0000400
    CRDLY    0003000   Select carriage-return delays:
    CR0      0000000
    CR1      0001000
    CR2      0002000
    CR3      0003000
    TABDLY   0014000   Select horizontal-tab delays:
    TAB0     0000000
    TAB1     0004000
    TAB2     0010000
    TAB3     0014000   Expand tabs to spaces.
    BSDLY    0020000   Select backspace delays:
    BS0      0000000
    BS1      0020000
    VTDLY    0040000   Select vertical-tab delays:
    VT0      0000000
    VT1      0040000
    FFDLY    0100000   Select formfeed delays:
    FF0      0000000
    FF1      0100000

    If OPOST is set, output characters are postprocessed as indicated by the
    remaining flags.  Otherwise, characters are transmitted without change.

    If OLCUC is set, a lowercase alphabetic character is transmitted as the
    corresponding uppercase character.  This function is often used 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 at column 0
    (first position).  If ONLRET is set, the NL character is assumed to
    perform 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 perform only the linefeed function; the column pointer will
    remain unchanged.  The column pointer is also set to 0 if the CR character
    is actually transmitted.



  2/94 - Intergraph Corporation                                              5






  termio(7)                           CLIX                           termio(7)



    The delay bits specify how long transmission stops to allow for mechanical
    or other movement when certain characters are sent to the terminal.  In
    all cases a value of 0 indicates no delay.  If OFILL is set, fill
    characters will be transmitted for delay instead of a timed delay.  This
    is useful for high baud rate terminals that need only a minimal delay.  If
    OFDEL is set, the fill character is DEL.  Otherwise, it is NUL.

    If a formfeed or vertical-tab delay is specified, it lasts for about two
    seconds.

    Newline delay lasts about 0.10 seconds.  If ONLRET is set, the carriage-
    return delays are used instead of the newline delays.  If OFILL is set,
    two fill characters will be transmitted.

    Carriage-return delay type 1 depends on the current column position; type
    2 is about 0.10 seconds and type 3 is about 0.15 seconds.  If OFILL is
    set, delay type 1 transmits two fill characters and type 2 transmits four
    fill characters.

    Horizontal-tab delay type 1 depends on the current column position.  Type
    2 is about 0.10 seconds.  Type 3 specifies that tabs are to be expanded
    into spaces.  If OFILL is set, two fill characters will be transmitted for
    any delay.

    Backspace delay lasts about 0.05 seconds.  If OFILL is set, one fill
    character will be transmitted.

    The actual delays depend on line speed and system load.

    The initial output control value is all bits clear.

    The c_cflag field describes the hardware control of the terminal:

    CBAUD    0000017   Baud rate:
    B0       0000000   Hang up
    B50      0000001   50 baud
    B75      0000002   75 baud
    B110     0000003   110 baud
    B134     0000004   134 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
    B19200   0000016   19200 baud





  6                                              Intergraph Corporation - 2/94






  termio(7)                           CLIX                           termio(7)



    EXTA     0000016   External A
    B38400   0000017   38400 baud
    EXTB     0000017   External B
    CSIZE    0000060   Character size:
    CS5      0000000   5 bits
    CS6      0000020   6 bits
    CS7      0000040   7 bits
    CS8      0000060   8 bits
    CSTOPB   0000100   Send two stop bits.  Otherwise, send one.
    CREAD    0000200   Enable receiver.
    PARENB   0000400   Enable parity.
    PARODD   0001000   Use odd parity.  Otherwise, use even.
    HUPCL    0002000   Hang up on last close.
    CLOCAL   0004000   Set local line.  Otherwise, set dial-up.
    LOBLK    0040000   Block layer output.

    The CBAUD bits specify the baud rate.  The zero baud rate, B0, hangs up
    the connection.  If B0 is specified, the data-terminal-ready signal will
    not be asserted.  Normally, this will disconnect the line.  For any
    particular hardware, impossible speed changes are ignored.

    The CSIZE bits specify the character size in bits for 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 is used.  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 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 LOBLK is set, the output of a job control layer will be blocked when it
    is not the current layer.  Otherwise, the output generated by that layer
    will be multiplexed onto the current layer.

    The initial hardware control value after open is B300, CS8, CREAD, HUPCL.

    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.



  2/94 - Intergraph Corporation                                              7






  termio(7)                           CLIX                           termio(7)



    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.
    ECHONL   0000100   Echo NL.
    NOFLSH   0000200   Disable flush after interrupt or quit.
    TOSTOP   0000400   SIGTTOU on background output.

    If ISIG is set, each input character is checked against the special
    control characters INTR, SWTCH, SUSP, 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 performed.
    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 (such as 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 or the timeout value TIME
    has expired between characters.  This allows fast bursts of input to be
    read efficiently while still allowing single character input.  The MIN and
    TIME values are stored in the position for the EOF and EOL characters,
    respectively.  The time value represents tenths of seconds.

    If XCASE and ICANON are set, an uppercase letter is accepted on input when
    it is preceded by a \ character and is output preceded by a \ character.
    In this mode, the following escape sequences are generated on output and
    accepted at input:

    For:   Use:

    *      \*
    |      \!
    ~      \^
    {      \(
    }      \)
    \      \\

    For example, A is input as \a, \n as \\n, and \N as \\\n.

    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.  Note that an escape character preceding



  8                                              Intergraph Corporation - 2/94






  termio(7)                           CLIX                           termio(7)



    the erase or kill character removes any special function.  If ECHONL is
    set, the NL character will be echoed even if ECHO is not set.  This is
    useful for terminals set to local echo (known as half duplex).  Unless
    escaped, the EOF character is not echoed.  EOT being the default EOF
    character 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, switch, and interrupt characters will not be
    performed.

    If TOSTOP is set, background processes attempting to write to a
    controlling terminal will generate a SIGTTOU signal sent to all processes
    with the associated control terminal.

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

    The primary ioctl() functions have the following form:

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

    The requests using this form are as follows:

    TCGETA    Gets the parameters associated with the terminal and stores in
              the termio structure referenced by arg.

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

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

    TCSETAF   Waits for the output to drain, flushes the input queue, and sets
              the new parameters.

    Additional ioctl() calls have the following form:

    ioctl(fildes, request, arg)
    int arg;

    The requests using this form are as follows:

    TCSBRK   Waits for the output to drain.  If arg is 0, sends a break (zero
             bits for 0.25 seconds).

    TCXONC   Starts/stops control.  If arg is 0, suspends output; if 1,
             restarts suspended output.

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



  2/94 - Intergraph Corporation                                              9






  termio(7)                           CLIX                           termio(7)



  FILES

    /dev/tty   Terminal interface.

  RELATED INFORMATION

    Commands:  stty(1)

    Functions:  setpgrp(2), signal(2), fork(2), ioctl(2)













































  10                                             Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026