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

📄 tty.4

📁 UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱昂氏unix源代码分析都是用的该版
💻 4
字号:
.th TTY IV 5/27/74.sh NAMEtty \*- general typewriter interface.sh DESCRIPTIONThis section describesboth a particular special file,and the general nature of the typewriter interface..s3The file.it /dev/ttyis, in each process, a synonymfor the control typewriter associated with that process.It is useful for programs or Shell sequences which wish tobe sure of writing messages on the typewriterno matter how output has been redirected.It can also be used for programs which demand a file namefor output, when typed output is desiredand it is tiresome to find out which typewriteris currently in use..s3As for typewriters in general: all of the low-speed asynchronouscommunications ports use thesame general interface, no matter whathardware is involved.The remainder of this section discussesthe common features of the interface;the KL, DC, and DH writeups (IV) describepeculiarities of the individual devices..s3When a typewriter file is opened, it causesthe process to wait until a connection is established.In practice user's programs seldom open thesefiles; they are opened by.it initand become a user'sinput and output file.The very first typewriter file open in a process becomesthe.it "control typewriter"for that process.  The control typewriter plays a specialrole in handling quit or interrupt signals, as discussedbelow.The control typewriter is inherited by a child process during a.it fork..s3A terminal associated with one of these files ordinarilyoperates in full-duplex mode.  Characters may be typed at any time,even while output is occurring, and are only lost when thesystem's character input buffers become completelychoked, which is rare,or when the user has accumulated the maximum allowed number ofinput characters which have not yet been read by some program.Currently this limit is 256 characters.When the input limit is reached all thesaved characters are thrown away without notice..s3These special files have a number of modes which can be changedby use of the.it sttysystem call (II).When first opened,the interface mode is300 baud;either parity accepted;10 bits/character (one stop bit);and newline action character.Modes that can be changed by.it sttyincludethe interface speed (if the hardware permits);acceptance of even parity, odd parity, or both;a raw mode in which all characters may be read one at a time;a carriage return (CR) mode in whichCR is mapped into newline on input andeither CR or line feed (LF) cause echoing ofthe sequence LF-CR;mapping of upper case letters into lower case;suppression of echoing;a variety of delays after function characters;and the printing of tabs as spaces.See.it getty(VIII)for the way that terminal speed and type are detected..s3Normally, typewriter input is processed in units of lines.This means that a program attemptingto read will be suspended until an entire line has beentyped.  Also, no matter how many characters are requestedin the read call, at most one line will be returned.It is not however necessary to read a whole line atonce; any number of characters may berequested in a read, even one, without losing information..s3During input, erase and kill processing is normallydone.By default, the character `#' erases thelast character typed, except that it will not erasebeyond the beginning of a line or an EOT.By default, the character `@' kills the entireline up to the point where it was typed, but not beyond an EOT.  Both thesecharacters operate on a keystroke basis independentlyof any backspacing or tabbing that may have been done.Either `@' or `#' may be entered literally by precedingit by `\\';the erase or kill character remains, but the`\\' disappears.These two characters may be changed to others..s3When desired,all upper-case letters are mapped intothe corresponding lower-case letter.The upper-case letter may be generated by precedingit by `\\'.In addition, the following escape sequences are generatedon output and accepted on input:.s3.lp +14 7for	use.lp +15 7\*g	\\\*a.lp +15 7.br|	\\!.br.tr ??.lp +15 7~	\\^.lp +15 7{	\\(.lp +15 7}	\\).s3.i0In raw mode,the programreading is awakened on each character.No erase or kill processing is done;and the EOT, quit and interrupt charactersare not treated specially.The input parity bit is passed back to the reader,but parity is still generated for output characters..s3The ASCII EOT (control-D) character may be used to generate an end of filefrom a typewriter.When an EOT is received, all the characterswaiting to be read are immediately passed tothe program, without waiting for a new-line,and the EOT is discarded.Thus if there are no characters waiting, whichis to say the EOT occurred at the beginning of a line,zero characters will be passed back, and this isthe standard end-of-file indication.The EOT is passed back unchanged in raw mode..s3When the carrier signal from the dataset drops (usuallybecause the user has hung up his terminal)a.it hangupsignal is sent to all processes with the typewriteras control typewriter.Unless other arrangements have been made,this signal causes the processes to terminate.If the hangup signal is ignored, any readreturns with an end-of-file indication.Thus programs which read a typewriter and test forend-of-file on their inputcan terminate appropriately whenhung up on..s3Two characters have a special meaning when typed.The ASCII DEL character (sometimes called `rubout')is not passed to a program but generatesan.it interruptsignalwhich is sent to all processes with the associated control typewriter.Normally each such process is forced to terminate,but arrangements may be made either toignore the signal or to receive atrap to an agreed-upon location.See.it signal(II)..s3The ASCII character FS generates the.it quitsignal.Its treatment is identical to the interrupt signalexcept that unless a receiving process hasmade other arrangements it will not only be terminatedbut a core image file will be generated.If you find it hard to type this character,try control-\\ or control-shift-L..s3When one or morecharacters are written, they are actually transmittedto the terminal as soon as previously-written charactershave finished typing.Input characters are echoed by putting them in the output queueas they arrive.When 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 thresholdthe program is resumed.Even parity is always generated on output.The EOT character is not transmitted(except in raw mode)to prevent terminalswhich respond to it from hanging up..sh FILES/dev/tty.sh "SEE ALSO"dc (IV), kl (IV), dh (IV), getty (VIII), stty (I, II), gtty (I, II), signal (II).sh BUGSHalf-duplex terminals are not supported.On raw-mode output, parity should be transmitted as specifiedin the characters written.

⌨️ 快捷键说明

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