Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stty(1)

fork(2)

ioctl(2)

setpgrp(2)

signal(2)

setpgid(2)

ioctl(2-BSD)

tty(4-BSD)

setpgrp(2-BSD)

kopt(8)



TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



NAME
     termio - general terminal interface

DESCRIPTION
     All of the asynchronous communications ports and network
     virtual terminal (``pseudo-terminal'' or ``pty'') ports use
     the same general interface, no matter what hardware is
     involved.  The remainder of this section discusses the com-
     mon features of this interface.

     When a terminal file is opened, it normally causes the pro-
     cess to wait until a connection is established.  In prac-
     tice, users' programs seldom open terminal 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
     session process group leader of a terminal file not already
     associated with a process group becomes the control terminal
     for that session 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)
     or by using the ioctl(2) command TIOCNOTTY (see below).

     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 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 thrown away without
     notice.

     There are several modes in which terminal input may be pro-
     cessed, called "line disciplines."  Line discipline 0
     (``LDISC0'') is compatible with System V Release 3.0 and 4.3
     BSD ``old'' line discipline terminal input processing.  Line
     discipline 2 (``LDISC_NEW'') is compatible with the 4.3 BSD
     ``new'' line discipline terminal input processing.  Line
     discipline 1 (``LDISC1'') is a hybrid of the other two.  The
     following discussion of the terminal interface will note
     where these line disciplines differ.

     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 charac-
     ter.  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, however,



                        Printed 11/19/92                   Page 1





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     necessary to read a whole line at once; any number of char-
     acters may be requested in a read, even one, without losing
     information.

     During input, erase and kill processing is normally done.
     By default, the character # erases the last character typed,
     except that 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 charac-
     ter.  Both these characters operate on a key-stroke basis,
     independently of any backspacing or tabbing that may have
     been done.  Both the erase and kill characters may be
     entered literally by preceding them with the escape charac-
     ter (\ in LDISC0, Control-V in LDISC1 and LDISC_NEW).  In
     this case the escape character is not read.  The erase,
     kill, and escape characters may be changed.

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

     INTR    (Rubout or ASCII DEL) generates an interrupt signal
             which is sent to all processes in the foreground job
             control process group of the associated control ter-
             minal.  (See setpgid(2) and setpgrp(2-BSD) for a
             discussion of how to change the job control process
             group of a process.  See the discussion of the
             ioctl(2) command TIOCSPGRP below for a discussion of
             how to change the foreground job control process
             group of a terminal.  Unless otherwise changed, the
             session process group, the job control process
             group, and the foreground job control process group
             are all identical.)  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 not only be terminated
             but a core image file (called core) will be created
             in the current working directory.

     SWTCH   (Control-z or ASCII SUB when shl is in use, unde-
             fined otherwise) is used by the System V job control
             facility, shl, to change the current layer to the
             control layer.  (Note that shl is not currently sup-
             ported in RISC/os.)

     ERASE   (#) erases the preceding character.  It will not
             erase beyond the start of a line, as delimited by a



 Page 2                 Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



             NL, EOF, or EOL character.

     KILL    (@) 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 discarded.  Thus, if there are no charac-
             ters 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 indi-
             cation.  (In LDISC1, if characters are waiting to be
             read when the EOF is entered, they are immediately
             passed to the current read from the program, and
             then the following read from the program will
             receive zero characters.)

     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.

     EOL2    (ASCII NUL) is another additional line delimiter.

     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, and in providing flow control of communication
             between computers.  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.

     SUSP    (undefined) is the job control stop character in
             LDISC1 and LDISC_NEW. Job control shells normally
             set it to Control-z.  When defined and entered, this
             character causes a SIGTSTP signal (see signal(2)) to
             be sent to the current foreground job control pro-
             cess group.  Unless caught by the application, this
             will cause the application to stop and wait to be
             continued, and will cause the job control shell to
             resume prompting for commands.

     DSUSP   (undefined) is the job control stop character in
             LDISC1 and LDISC_NEW. Job control shells normally
             set it to Control-y.  When defined and entered, this



                        Printed 11/19/92                   Page 3





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



             character causes a SIGTSTP signal (see signal(2)) to
             be sent to the current foreground job control pro-
             cess group, when the next read from the terminal is
             started (or immediately if a read is pending).
             Unless caught by the application, this will cause
             the application to stop and wait to be continued,
             and will cause the job control shell to resume
             prompting for commands.

     RPRNT   (undefined in LDISC0, Control-R in LDISC1 and
             LDISC_NEW) causes a newline to be output and the
             current input line to be retyped on the output.
             This is convenient in checking what has been typed,
             if echoing was interrupted by application output.

     FLUSH   (undefined in LDISC0, Control-O in LDISC1 and
             LDISC_NEW) causes all pending output to be dis-
             carded.  Also, in LDISC_NEW, all output will con-
             tinue to be discarded until either another FLUSH
             character is entered or the application turns off
             flushing of output.  (Thus, in LDISC_NEW, FLUSH tog-
             gles whether output is printed or discarded.)  This
             function is convenient when a command produces a
             large amount of unexpected and undesired output, yet
             the user does not wish to terminate the command.

     WERASE  (undefined in LDISC0, Control-W in LDISC1 and
             LDISC_NEW) causes any immediately preceding blank
             (space or ASCII TAB) characters, plus any preceding
             contiguous sequence of non-blank characters, to be
             deleted.  This effectively deletes the previous word
             of input.

     STATUS  (undefined) causes the status of some process in the
             associated session process group to be displayed,
             preceded and followed by newlines.  (Conventionally,
             this character, when enabled, is set to Control-T.)
             In selecting the process whose status is to be
             displayed, preference is given to processes which
             are in the foreground job control process group, and
             within that group, first, to processes which are
             running or runnable, second, to processes which are
             waiting for some event, and, last, to other
             processes.  The line of status consists of, in
             order, the process's name, id, run status, user CPU
             time in seconds, system CPU time in seconds, count
             of blocks read, count of blocks written, and memory
             size in pages.  This feature is convenient in moni-
             toring the progress of a long running interactive
             command.





 Page 4                 Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     The character values for all of the control characters,
     except NL, may be changed to suit individual tastes.  In
     LDISC0, the ERASE, KILL, and EOF characters may be escaped
     by a preceding ESCAPE character, in which case no special
     function is done.  In LDISC1 and LDISC_NEW, any character,
     including the ESCAPE character, may be escaped by a preced-
     ing ESCAPE character.

     When the carrier signal from the data-set drops, a hang-up
     (SIGHUP) signal is sent to all processes that have this ter-
     minal as the control terminal, and which are in its fore-
     ground job control process group, unless this feature has
     been disabled.  Unless other arrangements have been made,
     this signal causes the processes to terminate.  If the
     hang-up signal is ignored, any subsequent read returns with
     an end-of-file indication.  Thus, programs that read a ter-
     minal and test for end-of-file can terminate appropriately
     when hung up on.

     When one or more characters are written, they are transmit-
     ted to the terminal as soon as previously-written characters
     have finished typing.  If echoing is enabled, input charac-
     ters are echoed by putting them (or, in the case of control
     characters, a transformed version, if so enabled in
     LDISC_NEW) in the output queue as they arrive.  (The
     Control-D character, ASCII EOT, however, is never echoed as
     itself.  Also, in LDISC1 and LDISC_NEW, it is echoed as "^D"
     followed by two ASCII BS characters.) If ``control character
     echoing'' mode is enabled in LDISC_NEW, control characters
     are echoed as ``^X'', where ``X'' is the character obtained
     by adding 0100 to the character code of the control charac-
     ter.  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  23
     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 */
            unsigned    short   c_saved_flags;  /* (bsd43) saved flags */
            unsigned    short   c_filler;
     };




                        Printed 11/19/92                   Page 5





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     The special control characters are defined by the array
     c_cc.  The character value 0377 is normally used as the
     value for elements of the array which are to be treated as
     being ``undefined.''  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   VEOL2           NUL
          7   VSWTCH          undefined
          8   V_START         Control-q
          9   V_STOP          Control-s
          10  V_SUSP          undefined
          11  V_DSUSP         undefined
          12  V_RPRNT         Control-r
          13  V_FLUSH         Control-o
          14  V_WERAS         Control-w
          15  V_LNEXT         \
          16  V_STATUS        undefined
          17  V_SAVED_EOF     undefined
          18  V_SAVED_EOL     undefined
          19  reserved        undefined
          20  reserved        undefined
          21  reserved        undefined
          22  reserved        undefined

     The elements V_SAVED_EOF and V_SAVED_EOL are used as part of
     the RISC/os emulation of 4.3 BSD terminal ioctl(2-BSD) con-
     trol commands, and are not normally modified directly by
     applications.

     The c_iflag field describes the basic terminal input con-
     trol:

          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 6                 Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            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.  Oth-
     erwise 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 charac-
     ters are ignored and not read.  If IXANY is set, any input
     character, will restart output which has been suspended.

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

     The initial input control value is ICRNL, IXON, IXANY,
     BRKINT, IGNPAR, and ISTRIP.

     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.
          ONLRET  0000040  NL performs CR function.
          OFILL   0000100  Use fill characters for delay.



                        Printed 11/19/92                   Page 7





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



          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 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 func-
     tion; the column pointer will remain unchanged.  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
     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 which need only a
     minimal delay.  If OFDEL is set, the fill character is DEL,
     otherwise NUL.



 Page 8                 Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     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 OPOST, ONLCR, and TAB3.

     The c_cflag field describes the hardware control of the ter-
     minal:

          CBAUD         0000017  Baud rate:
          B0            0        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
          EXTA          0000016  External A
          B38400        0000017  38400 baud
          EXTB          0000017  External B
          CSIZE         0000060  Character size:
          CS5           0        5 bits
          CS6           0000020  6 bits
          CS7           0000040  7 bits



                        Printed 11/19/92                   Page 9





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



          CS8           0000060  8 bits
          CSTOPB        0000100  Send two stop bits, else one.
          CREAD         0000200  Enable receiver.
          PARENB        0000400  Parity enable.
          PARODD        0001000  Odd parity, else even.
          HUPCL         0002000  Hang up on last close.
          CLOCAL        0004000  Local line, else dial-up.
          CNEW_RTSCTS   0020000  Use RTS/CTS handshaking.
          LOBLK         0040000  Block layer output.
          CNEW_MDMBUF   0100000  Start/stop output when carrier drops.

     The CBAUD bits specify the baud rate.  The zero baud rate,
     B0, is used to hang up the connection.  If B0 is specified,
     the data-terminal-ready signal will not be asserted.  Nor-
     mally, this will disconnect the line.  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, other-
     wise 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.  The terminal minor device i, 0<=i<=127, is the
     same as terminal minor device i+128, except that the CLOCAL
     default is inverted for one, relative to the other. This
     allows one to be used by default for applications such as
     dial-in modems or terminals which autologout when they are
     turned off, and the other to be used for dialout modems.

     If CNEW_RTSCTS is set, and the communications port supports
     it, RTS/CTS handshaking will be used.  When the input queue
     becomes nearly full, RTS will be dropped.  RTS will be
     reasserted when the input queue has drained sufficiently.
     Output is suspended when CTS is lowered and restarted when
     CTS is raised.





 Page 10                Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     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.

     If CNEW_MDMBUF is set, and the communications port supports
     it, output will be blocked when carrier drops and resumed
     when carrier returns.  This is useless unless CLOCAL is set,
     since otherwise the connection will be broken when carrier
     drops.

     The initial hardware control value after open has B9600,
     CS8, CREAD, CLOCAL, and HUPCL set, with two exceptions.
     First, the console and secondary console serial ports (gen-
     erally, /dev/tty0 and /dev/tty1) generally default to a baud
     rate specified by the system non-volatile configuration
     database, which is configurable by PROM monitor commands
     when the system is at the PROM monitor prompt.  Second, as
     noted in the discussion of CLOCAL, for hardware serial
     ports, such as /dev/tty1, /dev/ttyh1, /dev/ttyd1, and so on,
     the terminal minor device i, 0<=i<=127, is the same device
     as the terminal minor device i+128, except that the CLOCAL
     default is inverted for one, relative to the other. (The
     latter devices are conventionally named /dev/ttym1,
     /dev/ttymh1, /dev/ttymd1, and so on; see MKDEV(1m) and
     DEV_DB(4) for information on how the secondary names may be
     created.)  In the default system configuration, CLOCAL is
     set for the lower minor device number and not set for the
     higher minor device number. This default may be inverted,
     however, on a system wide basis by a system configuration
     option; see kopt(8).

     The c_lflag field of the argument structure is used by the
     line discipline to control terminal functions.  All line
     discipline provide 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.

     Line disciplines LDISC1 (1) and LDISC_NEW (2) provide the
     following additional option:

     TOSTOP          0100000  Send SIGTTOU on output by a background job

     Line discipline LDISC_NEW (2) provides the following addi-
     tional options:



                        Printed 11/19/92                  Page 11





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     LNEW_CTLECH     0002000  Echo control characters as ^X, delete as ^?
     LNEW_PRTERA     0004000  Printing terminal erase mode
     LNEW_CRTBS      0020000  Backspace on erase rather than echoing erase
     LNEW_PENDIN     0040000  Retype pending input at next read or input character
     LNEW_FLUSHO     0010000  Output is being flushed

     If ISIG is set, each input character is checked against the
     special control characters INTR, SWTCH, and QUIT, and also,
     in LDISC1 and LDISC_NEW, SUSP and DSUSP. If an input charac-
     ter 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 func-
     tions are possible only if ISIG is set.  These functions may
     be disabled individually by changing the value of the con-
     trol character to an unlikely or impossible value (e.g.,
     0377).  The value 0377, in particular, is reserved as the
     "undefined" value if the kernel configuration option
     ``_posix_vdisable'' is enabled (see kopt(8)); if this option
     is set, an input character with the value 0377 will not
     match against any control character.  Of course, if ISTRIP
     is set, and PARMRK is not set, it is not possible to enter a
     character with value 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 char-
     acters, respectively.  The time value represents tenths of
     seconds.

     If XCASE is set, and if ICANON is set, an upper-case letter
     is accepted on input by preceding it with a \ character, and
     is output preceded by a \ character.  In this mode, the fol-
     lowing 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.




 Page 12                Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     If ECHO is set, characters are echoed as received.

     When ICANON is set, the following echo functions are possi-
     ble.  If ECHO and ECHOE are set, the erase character is
     echoed as ASCII BS SP BS, which will clear the last charac-
     ter 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 charac-
     ter 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 will be echoed even if ECHO is not set.  This is
     useful for terminals set to local echo (so-called half
     duplex).  Unless escaped, the EOF character is not echoed.
     Because EOT is the default EOF character, this prevents ter-
     minals 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 char-
     acters will not be done.

     If LNEW_CTLECH is set, and the line discipline is LDISC_NEW,
     and ECHO is set, input control characters are echoed as
     ``^X'' (where ``X'' is the ASCII character obtained by
     adding 0100 to the character code of the control character)
     and input ASCII DEL characters are echoed as ``^?''.  As
     noted above, ASCII EOT is echoed as ``^D'' followed by two
     ASCII BS characters.

     If LNEW_PRTERA is set, and the line discipline is LDISC_NEW,
     deleted characters are echoed as they were when input,
     bracketed by a ``\'' on the left and a ``/'' on the right.

     If LNEW_FLUSHO is set, and the line discipline is LDISC1 or
     LDISC_NEW, any pending output is discarded. In LDISC1,
     LNEW_FLUSHO is reset immediately.  In LDISC_NEW, LNEW_FLUSHO
     is reset on input of a FLUSH character, or when the next
     read is attempted.

     If LNEW_CRTBS is set, and the line discipline is LDISC_NEW,
     and ECHO is set, and ECHOE is not set, deleted characters
     are echoed by one or more ASCII BS characters, sufficient to
     backspace over the output characters which echoed the origi-
     nal input character.  (If ECHOE is also set, it takes pre-
     cedence.)

     If LNEW_PENDIN is set, any pending input is re-echoed when
     the next read is attempted, and the flag is then reset.
     This flag may be used in conjunction with the TIOCSTI
     ioctl(2) command by an application to allow a user to edit a
     line of text using the terminal input editing facilities,
     and then return the edited data to the application by typing



                        Printed 11/19/92                  Page 13





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



     a newline.

     If TOSTOP is set, and job control is enabled for the termi-
     nal a background job (that is, a job which has a job control
     process group different from the process group of the termi-
     nal) which attempts to write to the terminal will be blocked
     from writing, and will be sent a SIGTTOU signal.  Job con-
     trol is enabled if the line discipline LDISC1 or LDISC_NEW
     and ISIG is set.

     The initial line-discipline control value has ISIG, ICANON,
     ECHO, and ECHOK set.

     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 termi-
                    nal and store in the termio structure refer-
                    enced by arg.

          TCSETA    Set the parameters associated with the termi-
                    nal 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)
          int arg;

     The commands using this form are:

          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



 Page 14                Printed 11/19/92





TERMIO(7)           RISC/os Reference Manual            TERMIO(7)



                    input and output queues.

     There are also a large number of additional ioctl(2) com-
     mands, described in tty(4-BSD), which are generally applica-
     ble to terminals, in conjunction with the above commands.
     The following are those which are generally useful:

          TIOCNOTTY     Disconnect from controlling terminal
          TIOCGPGRP     Get terminal process group
          TIOCSPGRP     Set terminal process group
          TIOCSTI       Insert character in terminal input stream
          TIOCSBRK      Enable break output
          TIOCCBRK      Disable break output
          TIOCSDTR      Set data terminal ready output
          TIOCCDTR      Clear data terminal ready output
          TIOCMSET      Set modem status
          TIOCMODS      Set modem status
          TIOCMGET      Get modem status
          TIOCMODG      Get modem status
          TIOCMBIS      Set modem status according to mask
          TIOCMBIC      Clear modem status according to mask
          TIOCEXCL      Set exclusive-use mode
          TIOCNXCL      Clear exclusive-use mode
          TIOCSTOP      Stop output (as if STOP character were typed)
          TIOCSTART     Start output (as if START character were typed)
          TIOCOUTQ      Return number of characters queued for output
          FIONREAD      Return number of characters available for input
          TIOCGWINSZ    Get window size information
          TIOCSWINSZ    Set window size information

     The tty(4-BSD) manual page also describes a number of addi-
     tional commands, which are provided for application compati-
     bility with 4.3 BSD. All of the functions of these addi-
     tional commands are, however, more easily obtained using the
     basic commands described above, such as TCGETA and TCSETA.
     See the pty(7) manual page for additional commands which
     apply only to pseudo-terminals.

FILES
     /dev/tty*

SEE ALSO
     stty(1) in the User's Reference Manual.
     fork(2), ioctl(2), setpgrp(2), signal(2), setpgid(2),
     ioctl(2-BSD), tty(4-BSD), setpgrp(2-BSD) in the Programmer's
     Reference Manual.
     kopt(8) in the System Administrator's Reference Manual.








                        Printed 11/19/92                  Page 15



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