man(1) Manual page archive

     TTYLD(4)                                                 TTYLD(4)

          ttyld - terminal processing

          #include <sgtty.h>

          This processing module is usually inserted into a stream(4)
          connected to a terminal device.  It gathers input into
          lines, performs erase and kill processing, and translates
          control sequences.

          Certain special characters have particular meaning on input.
          These characters are not passed to a program except in raw
          mode, where they lose their special character.  It is possi-
          ble to change these characters from the default.

          #    erases the last-typed character.  It will not erase
               beyond the beginning of a line or an EOT.

          @    erases the entire preceding part of the line, but not
               beyond an EOT.

          EOT  (Control-D) may be used to generate an end of file from
               a terminal.  When an EOT is received, all the charac-
               ters waiting to be read are immediately passed to the
               program, without waiting for a new-line, and the EOT is
               discarded.  Thus if there are no characters waiting,
               which is to say the EOT occurred at the beginning of a
               line, zero characters will be passed back, and this is
               the standard end-of-file indication.

          \    escapes a following erase, kill, or EOT character and
               allows it to be treated as ordinary data.

          DEL  is not passed to a program but generates the interrupt
               signal (2).  The signal is sent to any processes in the
               process group of the stream; see stream(4).

          FS   generates the quit signal (3).

          DC3  delays all printing on the terminal until something is
               typed in.

          DC1  restarts  printing after DC3 without generating any
               input to a program.

          Several ioctl(2) calls apply to terminals.  Most of them use
          the following structure, defined in <sgtty.h>:

     TTYLD(4)                                                 TTYLD(4)

               struct    sgttyb {
                    char sg_ispeed;
                    char sg_ospeed;
                    char sg_erase;
                    char sg_kill;
                    int  sg_flags;

          The sg_ispeed and sg_ospeed fields describe the input and
          output speeds of the device according to the following
          table.  They are not interpreted by the tty line discipline,
          but merely passed on to the device.  Devices ignore impossi-
          ble speed changes.  Symbolic values in the table are as
          defined in <sgtty.h>.

          B0      0    (hang up device)
          B50     1    50 baud
          B75     2    75 baud
          B110    3    110 baud
          B134    4    134.5 baud
          B150    5    150 baud
          B200    6    200 baud
          B300    7    300 baud
          B600    8    600 baud
          B1200   9    1200 baud
          B1800   10   1800 baud
          B2400   11   2400 baud
          B4800   12   4800 baud
          B9600   13   9600 baud
          EXTA    14   External A
          EXTB    15   External B

          The sg_erase and sg_kill fields of the argument structure
          specify the erase and kill characters respectively.
          (Defaults are # and @.)

          The sg_flags field of the argument structure contains sev-
          eral bits that determine the system's treatment of the ter-

          ALLDELAY 0177400 Delay algorithm selection
          VTDELAY  0040000 Select form-feed and vertical-tab delays:
          FF0      0
          FF1      0100000
          CRDELAY  0030000 Select carriage-return delays:
          CR0      0
          CR1      0010000
          CR2      0020000
          CR3      0030000
          TBDELAY  0006000 Select tab delays:
          TAB0     0
          TAB1     0001000

     TTYLD(4)                                                 TTYLD(4)

          TAB2     0004000
          XTABS    0006000
          NLDELAY  0001400 Select new-line delays:
          NL0      0
          NL1      0000400
          NL2      0001000
          NL3      0001400
          EVENP    0000200 Even parity allowed on input (most terminals)
          ODDP     0000100 Odd parity allowed on input
          RAW      0000040 Raw mode: wake up on all characters, 8-bit interface
          CRMOD    0000020 Map CR into LF; echo LF or CR as CR-LF
          ECHO     0000010 Echo (full duplex)
          LCASE    0000004 Map upper case to lower on input
          CBREAK   0000002 Return each character as soon as typed
          TANDEM   0000001 Automatic flow control

          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 a form-feed/vertical tab delay is specified, it lasts for
          about 2 seconds.

          Carriage-return delay type 1 lasts about .08 seconds.  Delay
          type 2 lasts about .16 seconds.  Delay type 3 is supposed to
          be for the Concept 100.

          New-line delay type 1 is supposed to be for the Teletype
          model 37.  Type 2 is about .10 seconds.  Type 3 is unimple-
          mented and is 0.

          Tab delay type 1 is supposed to be for the Teletype model
          37.  Type 3, called XTABS, is not a delay at all but causes
          tabs to be replaced by the appropriate number of spaces on

          In raw mode, every character is passed immediately to the
          program without waiting until a full line has been typed.
          No erase or kill processing is done; the end-of-file indica-
          tor (EOT), the interrupt character (DEL) and the quit char-
          acter (FS) are not treated specially.  There are no delays
          and no echoing, and no replacement of one character for
          another; characters are a full 8 bits for both input and

          Mode 020 causes input carriage returns to be turned into
          new-lines; input of either CR or LF causes LF-CR both to be
          echoed (for terminals without a new-line function).

          CBREAK is a sort of half-cooked mode.  Programs read each
          character as soon as typed, instead of waiting for a full

     TTYLD(4)                                                 TTYLD(4)

          line, but quit and interrupt work, and output delays CRMOD,
          XTABS, ECHO, and parity work normally.  On the other hand
          there is no erase or kill, and no special treatment of \ or

          TANDEM mode causes the system to produce a stop character
          (default DC3) whenever the input queue is in danger of over-
          flowing, and a start character (default DC1) when the input
          queue has drained sufficiently.  It is useful for flow con-
          trol when the `terminal' is actually another machine that
          obeys the conventions.

          Several ioctl calls have the form:

               #include <sgtty.h>

               ioctl(fildes, code, arg)
               struct sgttyb *arg;

          The applicable codes are:

               Fetch the parameters associated with the terminal, and
               store in the pointed-to structure.

               Set the parameters according to the pointed-to struc-
               ture.  These (equivalent) codes are synchronous with
               output data.

          The following codes affect characters that are special to
          the terminal interface.  The argument is a pointer to the
          following structure, defined in <sgtty.h>:

               struct tchars {
                      char    t_intrc   /* interrupt */
                      char    t_quitc;  /* quit */
                      char    t_startc; /* start output */
                      char    t_stopc;  /* stop output */
                      char    t_eofc;   /* end-of-file */
                      char    t_brkc;   /* input delimiter (like nl) */

          The default values for these characters are DEL, FS, DC1,
          DC3, EOT, and -1.  A character value of -1 eliminates the
          effect of that character.  The t_brkc character, by default
          -1, acts like a new-line in that it terminates a `line,' is
          echoed, and is passed to the program.  The `stop' and
          `start' characters may be the same, to produce a toggle
          effect.  It is counterproductive to make other special char-
          acters (including erase and kill) identical.

     TTYLD(4)                                                 TTYLD(4)

               Change the various special characters to those given in
               the structure.

               Fill in the structure with the current special charac-

          getty(8), stty(1), signal(2), ioctl(2), stream(4)