⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tty.4

📁 Unix操作系统minix 2.0源码
💻 4
📖 第 1 页 / 共 2 页
字号:


TTY(4)                    Minix Programmer's Manual                     TTY(4)


NAME
     tty, termios - terminals

DESCRIPTION
     The tty driver family takes care  of  all  user  input  and  output.   It
     governs  the  keyboard,  the  console, the serial lines, and pseudo ttys.
     Input on any of these devices undergoes "input  processing",  and  output
     undergoes  "output processing" according to the standard termios terminal
     interface.

  Input processing
     Each terminal device has an input queue.  This queue  is  used  to  store
     preprocessed  input  characters, and to perform the backspacing and erase
     functions.  Some special characters like a newline make the  contents  of
     the  queue  available to a process reading from the terminal.  Characters
     up to and including the newline, or another so-called "line  break",  may
     be  read by a process.  The process need not read all characters at once.
     An input line may be read byte by byte if one wants  to.   A  line  break
     just makes characters available for reading, thats all.

     When data is made available depends on whether the tty  is  in  canonical
     mode  or  not.   In  canonical  mode the terminal processes input line by
     line.  A line ends with a newline (NL), end-of-file (EOF), or end-of-line
     (EOL).   Characters that have not been delimited by such a line break may
     be erased one by one with the ERASE character or all  at  once  with  the
     KILL  character.   Once  a  line  break  is  typed  the characters become
     available to a reading process and can no longer be  erased.   Once  read
     they  are removed from the input queue.  Several lines may be gathered in
     the input queue if no reader is present to read them, but  a  new  reader
     will  only  receive  one line.  Two line breaks are never returned in one
     read call.  The input queue has a maximum length of MAX_CANON characters.
     Any  more  characters  are discarded.  One must use ERASE or KILL to make
     the  terminal  functioning  again  if  the  input  queue  fills  up.   If
     nonblocking  I/O  is  set then -1 is returned with errno set to EAGAIN if
     the reader would otherwise be blocked.

     In non-canonical mode (raw mode for short) all characters are immediately
     available  to the reader in principle.  One may however tune the terminal
     to bursty input with the  MIN  and  TIME  parameters,  see  the  raw  I/O
     parameters section below.  In raw mode no characters are discarded if the
     input queue threatens to overflow if the device supports flow control.

  Output processing
     Characters written to a terminal device may  undergo  output  processing,
     which  is  usually  just inserting a carriage returns before newlines.  A
     writer may return before all characters are output if the characters  can
     be  stored  in the output buffers.  If not then the writer may be blocked
     until space is available.  If non-blocking I/O is set then only the count
     of the number of bytes that can be processed immediately is returned.  If
     no characters can be written at all then -1 is returned with errno set to


                                                                             1



TTY(4)                    Minix Programmer's Manual                     TTY(4)


     EAGAIN.

  Special characters
     Some characters have special functions in some  of  the  terminal  modes.
     These  characters  are  as  follows,  with  the  Minix  defaults shown in
     parentheses:

     INTR (^?)
          Special input character that is recognized if  ISIG  is  set.   (For
          ISIG  and  other  flags  see  the various modes sections below.)  It
          causes a SIGINT signal to be sent to all processes in  the  terminal
          process group.  (See the section on session leaders below.)

     QUIT (^\)
          Special input character if ISIG is set.  Causes a SIGQUIT signal  to
          be sent to the terminal process group.

     ERASE (^H)
          Special input character if ICANON is set.  Erases the last character
          in the current line.

     KILL (^U)
          Special input character if ICANON is set.  Erases the entire line.

     EOF (^D)
          Special input character if ICANON  is  set.   It  is  a  line  break
          character  that is not itself returned to a reader.  If EOF is typed
          with no input present then the read  returns  zero,  which  normally
          causes the reader to assume that end-of-file is reached.

     CR (^M)
          Special input character if IGNCR or ICRNL is set.  It is a  carriage
          return  ('\r').   If IGNCR is set then CR is discarded.  If ICRNL is
          set and IGNCR is not set then CR is changed into an NL and  has  the
          same function as NL.

     NL (^J)
          Special input character if ICANON is set.   It  is  both  a  newline
          ('\n') and a line break.
          Special output character if OPOST  and  ONLCR  are  set.   A  CR  NL
          sequence  is output instead of just NL.  (Minix specific, but almost
          mandatory on any UNIX-like system.)

     TAB (^I)
          Special character on output if OPOST  and  XTABS  are  set.   It  is
          transformed  into  the  number of spaces necessary to reach a column
          position that is a multiple of eight.  (Only  needed  for  terminals
          without hardware tabs.)




                                                                             2



TTY(4)                    Minix Programmer's Manual                     TTY(4)


     EOL (undefined)
          Special input character if ICANON is set.  It is an additional  line
          break.

     SUSP (^Z)
          Special input character if job control is implemented  and  ISIG  is
          set.   It causes a SIGTSTP signal to be send to the terminal process
          group.  (Minix does not have job control.)

     STOP (^S)
          Special input character if IXON is set.  It suspends terminal output
          and is then discarded.

     START (^Q)
          Special output character if IXON is set.  It starts terminal  output
          if  suspended  and is then discarded.  If IXANY is also set then any
          other character also  starts  terminal  output,  but  they  are  not
          discarded.

     REPRINT (^R)
          Special input character if IEXTEN and ECHO are  set.   Reprints  the
          input  queue  from  the  last  line  break  onwards.  A reprint also
          happens automatically if the echoed input  has  been  messed  up  by
          other output and ERASE is typed.

     LNEXT (^V)
          Special input character if IEXTEN is set.  It is the "literal  next"
          character  that  causes  the  next character to be input without any
          special processing.

     DISCARD (^O)
          Special input character if IEXTEN  is  set.   Causes  output  to  be
          discarded  until  it is typed again.  (Implemented only under Minix-
          vmd.)

     All of these characters except CR, NL and TAB may be changed or  disabled
     under  Minix.   (Changes  to  START  and  STOP may be ignored under other
     termios implementations.)  The REPRINT and  LNEXT  characters  are  Minix
     extensions  that are commonly present in other implementations.  POSIX is
     unclear on whether IEXTEN, IGNCR and  ICRNL  should  be  active  in  non-
     canonical mode, but under Minix they are.

  Terminal attributes
     The attributes of  a  terminal,  such  as  whether  the  mode  should  be
     canonical  or  non-canonical,  are  controlled  by  routines that use the
     termios structure as defined in <termios.h>:

          struct termios {
              tcflag_t  c_iflag;       /* input modes */
              tcflag_t  c_oflag;       /* output modes */


                                                                             3



TTY(4)                    Minix Programmer's Manual                     TTY(4)


              tcflag_t  c_cflag;       /* control modes */
              tcflag_t  c_lflag;       /* local modes */
              speed_t   c_ispeed;      /* input speed */
              speed_t   c_ospeed;      /* output speed */
              cc_t      c_cc[NCCS];    /* control characters */
          };

     The types tcflag, speed_t and cc_t are defined in <termios.h> as unsigned
     integral types.

  Input Modes
     The c_iflag field contains the following single bit  flags  that  control
     input processing:

     ICRNL
          Map CR to NL on input.

     IGNCR
          Ignore CR on input.  This flag overrides ICRNL.

     INLCR
          Map NL to CR on input.  This is done after the IGNCR check.

     IXON Enable start/stop output control.

     IXOFF
          Enable start/stop input control.  (Not implemented.)

     IXANY
          Allow any character to restart output.  (Minix specific.)

     ISTRIP
          Strip characters to seven bits.

     IGNPAR
          Ignore characters with parity errors.  (Not implemented.)

     INPCK
          Enable input parity checking.  (Not implemented.)

     PARMRK
          Mark parity errors by preceding the faulty  character  with  '\377',
          '\0'.   The  character '\377' is preceded by another '\377' to avoid
          ambiguity.  (Not implemented.)

     BRKINT
          Send the signal SIGINT to the terminal process group when  receiving
          a break condition.  (Not implemented.)




                                                                             4



TTY(4)                    Minix Programmer's Manual                     TTY(4)


     IGNBRK
          Ignore break condition.  If neither BRKINT or IGNBRK is set a  break
          is  input  as  a  single  '\0', or if PARMRK is set as '\377', '\0',
          '\0'.  (Breaks are always ignored.)

  Output Modes
     The c_oflag field contains the following single bit  flags  that  control
     output processing:

     OPOST
          Perform output processing.  This flag is the "main switch" on output
          processing.  All other flags are Minix specific.

     ONLCR
          Transform an NL to a CR NL sequence on  output.   Note  that  a  key
          labeled  "RETURN"  or  "ENTER" usually sends a CR.  In line oriented
          mode this is normally transformed into  NL  by  ICRNL.   NL  is  the
          normal  UNIX  line delimiter ('\n').  On output an NL is transformed
          into the CR NL sequence that is necessary to reach the first  column
          of  the next line.  (This is a common output processing function for
          UNIX-like systems, but not always separately switchable by an  ONLCR
          flag.)

     XTABS
          Transform a TAB into the number  of  spaces  necessary  to  reach  a
          column position that is a multiple of eight.

     ONOEOT
          Discard EOT (^D) characters.  (Minix-vmd only.)

  Control Modes
     The c_cflag field contains the following single bit flags and  bit  field
     for basic hardware control:

     CLOCAL
          Ignore modem status lines.

     CREAD
          Enable receiver.  (The receiver is always enabled.)

     CSIZE
          Number of bits per byte.  CSIZE masks off the values CS5,  CS6,  CS7
          and CS8 that indicate that 5, 6, 7 or 8 bits are used.

     CSTOPB
          Send two stop bits instead of one.  Two stop bits are normally  used
          at 110 baud or less.





                                                                             5



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -