Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ termio(7) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                termio(7)



        _________________________________________________________________
        termio                                               Special File
        AT&T terminal interface
        _________________________________________________________________


        DESCRIPTION

        This entry discusses how the DG/UX system interfaces to
        terminals.  All of the asynchronous communications ports use the
        same general interface, no matter what hardware is involved.

        When a terminal file is opened, it normally causes the process to
        wait until a connection is established.  A user's program seldom
        opens these files; they are opened by getty and become a user's
        standard input, output, and error 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 handles quit and
        interrupt signals as discussed below.  See devtty(7) for a
        complete description of the control terminal.

        A terminal associated with a terminal file ordinarily operates in
        full-duplex mode.  You can type characters at any time, even
        during output; characters are lost only when you have accumulated
        256 input characters not yet read by some program.  When the
        input limit is reached, all the saved characters are thrown away
        without warning.

        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 an end-of-line character.  This means
        that a program trying 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 is returned.
        However, it is not necessary to read a whole line at once; in a
        read you can request any number of characters, even one, without
        losing information.

        Erase and kill processing is normally done during input.  By
        default, the character # erases the last character typed, but it
        will not erase beyond the beginning of the line.  By default, the
        character @ kills (deletes) the entire input line, and optionally
        outputs a new-line character.  Both characters operate on a
        keystroke basis, independent of any backspacing or tabbing that
        may have been done.  You can enter both the erase and kill
        characters literally by preceding them with the escape character
        (\).  The escape character is not read.  You can change the erase
        and kill characters.

        Certain characters have special functions on input.  These



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        functions and their default values are as follows:

        INTR    (Rubout or ASCII DEL) Generate an interrupt signal that
                is sent to all processes with the associated control
                terminal.  Normally, each of these processes is forced to
                terminate, but you can make the shell either ignore the
                signal or receive a trap to an agreed-upon location; see
                signal(2).

        QUIT    (Control-| or ASCII FS) Generate a quit signal.  It
                behaves like INTR, except that, unless a receiving
                process has made other arrangements, it terminates and a
                core image file (called core) is created in the current
                working directory.

        SWTCH   (Control-Z or ASCII SUB) Change the current layer to the
                control layer (used by the job control facility, shl).

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

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

        EOF     (Control-D or ASCII EOT) Generate an end-of-file from a
                terminal.  All the characters waiting to be read are
                immediately passed to the program without waiting for a
                new-line, and the EOF is discarded.  If no characters are
                waiting (the EOF occurred at the beginning of a line), no
                characters are passed back, which is the standard end-
                of-file indication.

        NL      (ASCII LF) Delimit a line.  This is the normal line
                delimiter and cannot be changed or escaped.

        EOL     (ASCII NUL) Delimit a line.  This line delimiter is not
                normally used.

        STOP    (Control-S or ASCII DC3) Suspend output temporarily.
                This character is useful with CRT terminals to prevent
                output from disappearing before it can be read.

        START   (Control-Q or ASCII DC1) Resume output suspended by a
                STOP character.  The START/STOP characters cannot be
                changed or escaped.

        The character values for INTR, QUIT, SWTCH, ERASE, KILL, EOF, and
        EOL may be changed to suit individual tastes.  The ERASE, KILL,
        and EOF characters may be escaped by a preceding \ character, in
        which case no special function is done.



        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        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
        terminates the processes.  If the hang-up 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 are written, they are transmitted to
        the terminal as soon as previously written characters have
        finished 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 typed, it is suspended
        when its output queue exceeds some limit.  When the queue shrinks
        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        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 ccc.
        The relative positions and initial values for each function are
        as follows:

             0   VINTR    DEL
             1   VQUIT    FS
             2   VERASE   #
             3   VKILL    @
             4   VEOF     EOT
             5   VEOL     NUL
             6   Reserved
             7   SWTCH    NUL
             8   VBSPACE  BSPACE

        The c_iflag field describes the basic terminal input control:










        DG/UX 4.00                                                 Page 3
               Licensed material--property of copyright holder(s)





                                                                termio(7)



             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 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:  that is, it 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 that
        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 that 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; 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 suspends output, and a received START character
        restarts output.  All START/STOP characters are ignored and not
        read.  If IXANY is set, any input character restarts output that
        has been suspended, even another STOP character.

        If IXOFF is set, the system transmits START/STOP characters when



        DG/UX 4.00                                                 Page 4
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        the input queue is nearly empty/full.

        The initial input control value is all-bits-clear.

        The c_oflag field specifies how the system treats 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 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 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

        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 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 performs a carriage return; the column pointer
        is set to 0 and the delays specified for CR are used.  Otherwise



        DG/UX 4.00                                                 Page 5
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        the NL character performs only a line feed; the column pointer
        stays the same.  The column pointer is also set to 0 if the CR
        character is actually transmitted.

        The delay bits specify how long transmission stops to allow
        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 NUL.

        If a form-feed or vertical-tab delay is specified, it lasts for
        about 2 seconds.

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

        Carriage-return delay type 1 is dependent 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, four fill characters.

        Horizontal-tab delay type 1 is dependent 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      0        Hang up
             B110    0000001  110 baud
             B134    0000002  134.5 baud
             B150    0000003  150 baud
             B300    0000004  300 baud
             B600    0000005  600 baud
             B1200   0000006  1200 baud
             B1800   0000007  1800 baud
             B2400   0000010  2400 baud
             B4800   0000011  4800 baud
             B9600   0000012  9600 baud
             B19200  0000013  19200 baud



        DG/UX 4.00                                                 Page 6
               Licensed material--property of copyright holder(s)





                                                                termio(7)



             B38400  0000014  38400 baud
                     0000015  Unused
             EXTA    0000016  External A
             EXTB    0000017  External B
             CSIZE   0000060  Character size:
             CS5     0        5 bits
             CS6     0000020  6 bits
             CS7     0000040  7 bits
             CS8     0000060  8 bits
             CSTOPB  0000100  Send two stop bits, else one.
             CREAD   0000200  Enable receiver.
             PARENB  0000400  Enable parity.
             PARODD  0001000  Odd parity, else even.
             HUPCL   0002000  Hang up on last close.
             CLOCAL  0004000  Local line, else dial-up.
             LOBLK   0010000  Block layer output.

        The CBAUD bits specify the baud rate.  The zero baud rate, B0,
        terminates the connection.  If B0 is specified, the data-
        terminal-ready signal is not asserted.  Normally, this
        disconnects the line.  Speed changes that are not supported by
        the underlying hardware are ignored.  The baud rates EXTA and
        EXTB are driver-specific, and the rates supported by a given
        device are listed in the manual entry for that device.

        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 is used.  For example, at 110 baud, two
        stop 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.

        LOBLK may be set to indicate that output from a layer should be
        blocked when the layer is not the active layer (see shl(1)).  The
        terminal driver takes no action when this character is received,
        other than to make it available to the user program normally.



        DG/UX 4.00                                                 Page 7
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        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.
             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.

        If ISIG is set, each input character is checked against the
        special control characters INTR, SWTCH, 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.  You can disable these functions
        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 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 is set, and if ICANON is set, an uppercase letter is
        accepted on input by preceding it with a \ character, and is
        output preceded by a \ character.  In this mode, the following
        escape sequences are generated on output and accepted on input:

             For: Use:
             `    \'
             |    \!
             ~    \^
             {    \(
             }    \)
             \    \\

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




        DG/UX 4.00                                                 Page 8
               Licensed material--property of copyright holder(s)





                                                                termio(7)



        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 clears 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 is echoed
        after the kill character to emphasize that the line will be
        deleted.  Note that an escape character preceding the erase or
        kill character removes any special function.  If ECHONL is set,
        the NL character is echoed even if ECHO is not set.  This is
        useful for terminals set to local echo (half duplex).  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, switch, and interrupt characters will
        not be done.

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

        The primary ioctl 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 calls have the form:

             ioctl (fildes, command, arg)
             int arg;

        The commands using this form are:




        DG/UX 4.00                                                 Page 9
               Licensed material--property of copyright holder(s)





                                                                termio(7)



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

             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.


        WARNING

        The DG/UX System supports two distinct terminal drivers, the AT&T
        driver and the BSD driver.  In a few cases, mode changes using
        the AT&T modes and ioctls can not be accurately reflected in the
        BSD mode set, so a program that changes modes using AT&T ioctls
        must take care that the intent of the mode changes will be
        reflected for terminals using the BSD line driver.  The manual
        entry modemap(7) describes the manner in which modes are mapped
        between the two terminal drivers.


        FILES

        /dev/tty*


        SEE ALSO

        stty(1), fork(2), ioctl(2), setpgrp(2), signal(2), modemap(7),
        tty(7).






















        DG/UX 4.00                                                Page 10
               Licensed material--property of copyright holder(s)



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