📄 tty.4
字号:
.TH TTY 4.SH NAMEtty, termios \- terminals.SH DESCRIPTIONThe.B ttydriver family takes care of all user input and output. It governs thekeyboard, the console, the serial lines, and pseudo ttys. Input on any ofthese devices undergoes "input processing", and output undergoes "outputprocessing" according to the standard termios terminal interface..SS "Input processing"Each terminal device has an input queue. This queue is used to storepreprocessed input characters, and to perform the backspacing and erasefunctions. Some special characters like a newline make the contents of thequeue available to a process reading from the terminal. Characters up toand including the newline, or another so-called "line break", may be read bya process. The process need not read all characters at once. An input linemay be read byte by byte if one wants to. A line break just makescharacters available for reading, thats all..PPWhen data is made available depends on whether the tty is in canonical modeor not. In canonical mode the terminal processes input line by line. Aline ends with a newline.RB ( NL ),end-of-file.RB ( EOF ),or end-of-line.RB ( EOL ).Characters that have not been delimited by such a line break may be erasedone by one with the.B ERASEcharacter or all at once with the.B KILLcharacter. Once a line break is typed the characters become available to areading process and can no longer be erased. Once read they are removedfrom the input queue. Several lines may be gathered in the input queue ifno reader is present to read them, but a new reader will only receive oneline. Two line breaks are never returned in one read call. The input queuehas a maximum length of.B MAX_CANONcharacters. Any more characters are discarded. One must use.B ERASEor.B KILLto make the terminal functioning again if the input queue fills up. Ifnonblocking I/O is set then \-1 is returned with.B errnoset to.B EAGAINif the reader would otherwise be blocked..PPIn non-canonical mode (raw mode for short) all characters are immediatelyavailable to the reader in principle. One may however tune the terminal tobursty input with the.B MINand.B TIMEparameters, see the raw I/O parameters section below. In raw mode nocharacters are discarded if the input queue threatens to overflow if thedevice supports flow control..SS "Output processing"Characters written to a terminal device may undergo output processing, whichis usually just inserting a carriage returns before newlines. A writermay return before all characters are output if the characters can be storedin the output buffers. If not then the writer may be blocked until space isavailable. If non-blocking I/O is set then only the count of the number ofbytes that can be processed immediately is returned. If no characters canbe written at all then \-1 is returned with.B errnoset to.BR EAGAIN ..SS "Special characters"Some characters have special functions in some of the terminal modes. Thesecharacters are as follows, with the Minix defaults shown in parentheses:.TP 5.BR INTR " (^?)"Special input character that is recognized if.B ISIGis set. (For.B ISIGand other flags see the various modes sections below.) It causes a.B SIGINTsignal to be sent to all processes in the terminal process group. (See thesection on session leaders below.).TP.BR QUIT " (^\e)"Special input character if.B ISIGis set. Causes a.B SIGQUITsignal to be sent to the terminal process group..TP.BR ERASE " (^H)"Special input character if.B ICANONis set. Erases the last character in the current line..TP.BR KILL " (^U)"Special input character if.B ICANONis set. Erases the entire line..TP.BR EOF " (^D)"Special input character if.B ICANONis set. It is a line break character that is not itself returned to areader. 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..TP.BR CR " (^M)"Special input character if.B IGNCRor.B ICRNLis set. It is a carriage return ('\er'). If.B IGNCRis set then.B CRis discarded. If.B ICRNLis set and.B IGNCRis not set then.B CRis changed into an.B NLand has the same function as.BR NL..TP.BR NL " (^J)"Special input character if.B ICANONis set. It is both a newline ('\en') and a line break..brSpecial output character if.B OPOSTand.B ONLCRare set. A.B CR NLsequence is output instead of just.BR NL .(Minix specific, but almost mandatory on any UNIX-like system.).TP.BR TAB " (^I)"Special character on output if.B OPOSTand.B XTABSare set. It is transformed into the number of spaces necessary to reach acolumn position that is a multiple of eight. (Only needed for terminalswithout hardware tabs.).TP.BR EOL " (undefined)"Special input character if.B ICANONis set. It is an additional line break..TP.BR SUSP " (^Z)"Special input character if job control is implemented and.B ISIGis set. It causes a.B SIGTSTPsignal to be send to the terminal process group. (Minix does not have jobcontrol.).TP.BR STOP " (^S)"Special input character if.B IXONis set. It suspends terminal output and is then discarded..TP.BR START " (^Q)"Special output character if.B IXONis set. It starts terminal output if suspended and is then discarded. If.B IXANYis also set then any other character also starts terminal output, but theyare not discarded..TP.BR REPRINT " (^R)"Special input character if.B IEXTENand.B ECHOare set. Reprints the input queue from the last line break onwards. Areprint also happens automatically if the echoed input has been messed up byother output and.B ERASEis typed..TP.BR LNEXT " (^V)"Special input character if.B IEXTENis set. It is the "literal next" character that causes the next characterto be input without any special processing..TP.BR DISCARD " (^O)"Special input character if.B IEXTENis set. Causes output to be discarded until it is typed again. (Implementedonly under Minix-vmd.).PPAll of these characters except.BR CR ,.B NLand.B TABmay be changed or disabled under Minix. (Changes to.B STARTand.B STOPmay be ignored under other termios implementations.) The.B REPRINTand.B LNEXTcharacters are Minix extensions that are commonly present in otherimplementations. \s-2POSIX\s+2 is unclear on whether.BR IEXTEN,.BR IGNCRand.BR ICRNLshould be active in non-canonical mode, but under Minix they are..SS "Terminal attributes"The attributes of a terminal, such as whether the mode should be canonical ornon-canonical, are controlled by routines that use the.B termiosstructure as defined in.BR <termios.h> :.PP.RS.nf.ta +4n +10n +15nstruct termios { tcflag_t c_iflag; /* input modes */ tcflag_t c_oflag; /* output modes */ 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 */};.fi.RE.PPThe types.BR tcflag ,.B speed_tand.B cc_tare defined in.B <termios.h>as unsigned integral types..SS "Input Modes"The.B c_iflagfield contains the following single bit flags that control input processing:.TP 5.B ICRNLMap.B CRto.B NLon input..TP.B IGNCRIgnore.B CRon input. This flag overrides.BR ICRNL ..TP.B INLCRMap.B NLto.B CRon input. This is done after the.B IGNCRcheck..TP.B IXONEnable start/stop output control..TP.B IXOFFEnable start/stop input control. (Not implemented.).TP.B IXANYAllow any character to restart output. (Minix specific.).TP.B ISTRIPStrip characters to seven bits..TP.B IGNPARIgnore characters with parity errors. (Not implemented.).TP.B INPCKEnable input parity checking. (Not implemented.).TP.B PARMRKMark parity errors by preceding the faulty character with '\e377', '\e0'.The character '\e377' is preceded by another '\e377' to avoid ambiguity.(Not implemented.).TP.B BRKINTSend the signal.B SIGINTto the terminal process group when receiving a break condition. (Notimplemented.).TP.B IGNBRKIgnore break condition. If neither.B BRKINTor.B IGNBRKis set a break is input as a single '\e0', or if.B PARMRKis set as '\e377', '\e0', '\e0'.(Breaks are always ignored.).SS "Output Modes"The.B c_oflagfield contains the following single bit flags that control output processing:.TP.B OPOSTPerform output processing. This flag is the "main switch" on outputprocessing. All other flags are Minix specific..TP.B ONLCRTransform an.B NLto a.B CR NLsequence on output. Note that a key labeled "RETURN" or "ENTER" usuallysends a.BR CR .In line oriented mode this is normally transformed into.B NLby.BR ICRNL ..B NLis the normal UNIX line delimiter ('\en'). On output an.B NLis transformed into the.B CR NLsequence that is necessary to reach the first column of the next line.(This is a common output processing function for UNIX-like systems, but notalways separately switchable by an.B ONLCRflag.).TP.B XTABSTransform a.B TABinto the number of spaces necessary to reach a column position that is amultiple of eight..TP.B ONOEOTDiscard.B EOT(^D) characters. (Minix-vmd only.).SS "Control Modes"The.B c_cflagfield contains the following single bit flags and bit field for basichardware control:.TP.B CLOCALIgnore modem status lines..TP.B CREAD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -