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

📄 tty.4

📁 操作系统设计与实现源码
💻 4
📖 第 1 页 / 共 2 页
字号:
Enable receiver.  (The receiver is always enabled.).TP.B CSIZENumber of bits per byte..B CSIZEmasks off the values.BR CS5 ,.BR CS6 ,.BR CS7and.BR CS8that indicate that 5, 6, 7 or 8 bits are used..TP.B CSTOPBSend two stop bits instead of one.  Two stop bits are normally used at 110baud or less..TP.B PARENBEnable parity generation..TP.B PARODDGenerate odd parity if parity is generated, otherwise even parity..TP.B HUPCLDrop the modem control lines on the last close of the terminal line.  (Notimplemented.).SS "Local Modes"The.B c_lflagfield contains the following single bit flags that control various functions:.TP.B ECHOEnable echoing of input characters.  Most input characters are echoed asthey are.  Control characters are echoed as .BI "^" Xwhere.I Xis the letter used to say that the control character is.BI CTRL\- X\fR.The.BR CR ,.BR NLand.BR TABcharacters are echoed with their normal effect unless they are escaped by.BR LNEXT ..TP.B ECHOEIf.B ICANONand.B ECHOare set then echo.B ERASEand.B KILLas one or more backspace-space-backspace sequences to wipe out the lastcharacter or the entire line, otherwise they are echoed as they are..TP.B ECHOKIf.B ICANONand.B ECHOare set and.B ECHOEis not set then output an.B NLafter the.B KILLcharacter.  (For hardcopy terminals it is best to unset.B ECHOEand to set.BR ECHOK .).TP.B ECHONLEcho.B NLeven if.B ECHOis not set, but.B ICANONis set..TP.B ICANONCanonical input.  This enables line oriented input and erase and killprocessing..TP.B IEXTENEnable implementation defined input extensions..TP.B ISIGEnable the signal characters.BR INTR ,.BR QUITand.BR SUSP ..TP.B NOFLSHDisable the flushing of the input and output queues that is normally done ifa signal is sent..TP.B TOSTOPSend a.B SIGTTOUsignal if job control is implemented and a background process tries towrite.  (Minix has no job control.).SS "Input and output speed"The input and output speed are encoded into the.B c_ispeedand.B c_ospeedfields..B <termios.h>defines the symbols.BR B0 ,.BR B50 ,.BR B75 ,.BR B110 ,.BR B134 ,.BR B150 ,.BR B200 ,.BR B300 ,.BR B600 ,.BR B1200 ,.BR B1800 ,.BR B2400 ,.BR B4800 ,.BR B9600 ,.BR B19200 ,.BR B38400 ,.BR B57600and.BR B115200as values used to indicate the given baud rates.  The zero baud rate,.BR B0 ,if used for the input speed causes the input speed to be equal to theoutput speed.  Setting the output speed to zero hangs up the line.  Oneshould use the functions.BR cfgetispeed() ,.BR cfgetospeed() ,.BR cfsetispeed()and.BR cfsetospeed()to get or set a speed, because the.B c_ispeedand.B c_ospeedfields may not be visible under other implementations.  (The.B c_ispeedand.B c_ospeedfields and the.B B57600and.B B115200symbols are Minix specific.).SS "Special characters"The.B c_ccarray contains the special characters that can be modified.  The array haslength.B NCCSand is subscripted by the symbols.BR VEOF ,.BR VEOL ,.BR VERASE ,.BR VINTR ,.BR VKILL ,.BR VMIN ,.BR VQUIT ,.BR VTIME ,.BR VSUSP ,.BR VSTART ,.BR VSTOP ,.BR VREPRINT ,.BR VLNEXTand.BR VDISCARD .All these symbols are defined in.BR <termios.h> .Some implementations may give the same values to the.B VMINand.B VTIMEsubscripts and the.B VEOFand.B VEOLsubscripts respectively, and may ignore changes to.B STARTand.BR STOP .(Under Minix all special characters have there own.I c_ccslot and can all be modified.).SS "Raw I/O Parameters"The.B MINand.B TIMEparameters can be used to adjust a raw connection to bursty input..B MINrepresents a minimum number of bytes that must be received before a readcall returns..B TIMEis a timer of 0.1 second granularity that can be used to time out a read.Setting either of these parameters to zero has special meaning, which leadsto the following four possibilities:.TP 5.B "MIN > 0, TIME > 0".B TIMEis an inter-byte timer that is started (and restarted) when a byte isreceived.  A read succeeds when either the minimum number of charactersis received or the timer expires.  Note that the timer starts.B afterthe first character, so the read returns at least one byte..TP.B "MIN > 0, TIME = 0"Now the timer is disabled, and a reader blocks indefinitely until at least.B MINcharacters are received..TP.B "MIN = 0, TIME > 0".B TIMEis now a read timer that is started when a read is executed.  The read willreturn if the read timer expires or if at least one byte is input.  (Notethat a value of zero may be returned to the reader.).TP.B "MIN = 0, TIME = 0"The bytes currently available are returned.  Zero is returned if no bytesare available..SS "User Level Functions"Termios attributes are set or examined, and special functions can beperformed by using the functions described in.BR termios (2)..SS "Session Leaders and Process Groups"With the use of the.B setsid()function can a process become a session leader.  A session leader forms aprocess group with a process group id equal to the process id of the sessionleader.  If a session leader opens a terminal device file then this terminalbecomes the controlling tty of the session leader.  Unless the terminal isalready the controlling tty of another process, or unless the.B O_NOCTTYflag is used to prevent the allocation of a controlling tty.  The processgroup of the session leader is now remembered as the terminal process groupfor signals sent by the terminal driver.  All the children and grandchildrenof the session leader inherit the controlling terminal and process groupuntil they themselves use.BR setsid() ..PPThe controlling tty becomes inaccessible to the children of the sessionleader when the session leader exits, and a hangup signal is sent to allthe members of the process group.  The input and output queues are flushedon the last close of a terminal and all attributes are reset to the defaultstate..PPA special device.B /dev/ttyis a synonym for the controlling tty of a process.  It allows a process toreach the terminal even when standard input, output and error areredirected.  Opening this device can also be used as a test to see if aprocess has a controlling tty or not..PPFor Minix a special write-only device.B /dev/logexists for processes that want to write messages to the system console.Unlike the console this device is still accessible when a session leaderexits..PPMinix-vmd also has a.B /dev/logdevice, but this device is read-write.  All messages written to the logdevice or to the console when X11 is active can be read from.BR /dev/log .The system tries to preserve the log buffer over a reboot so that panicmessages reappear in the log if the system happens to crash..SS "Pseudo Terminals"Pseudo ttys allow a process such as a remote login daemon to set up aterminal for a remote login session.  The login session uses a device like.B /dev/ttyp0for input and output, and the remote login daemon uses the device.B /dev/ptyp0to supply input to or take output from the login session and transfer thisto or from the originating system.  So the character flow may be:  Localuser input sent to the remote system is written to.B /dev/ptyp0by the remote login daemon, undergoes input processing and appears on.B /dev/ttyp0as input to the login session.  Output from the login session to.B /dev/ttyp0undergoes output processing, is read from.B /dev/ptyp0by the remote login daemon and is send over to the local system to bedisplayed for the user.  (So there are only four data streams to worry aboutin a pseudo terminal.).PPA pseudo terminal can be allocated by trying to open all the controllingdevices.BI /dev/pty nnone by one until it succeeds.  Further opens will fail once a pty is open.The process should now fork, the child should become session leader, openthe tty side of the pty and start a login session..PPIf the tty side is eventually closed down then reads from the pty side willreturn zero and writes return \-1 with.B errnoset to.BR EIO .If the pty side is closed first then a.B SIGHUPsignal is sent to the session leader and further reads from the tty sidereturn zero and writes return \-1 with.B errnoset to.BR EIO .(Special note:  A line erase may cause up to three times the size of thetty input queue to be sent to the pty reader as backspace overstrikes.  Someof this output may get lost if the pty reader cannot accept it all at oncein a single read call.).SS "Backwards compatibility"The.BR TIOCGETP ,.BR TIOCSETP ,.BR TIOCGETCand.BR TIOCSETCioctl functions that are used by the old.B sgttyterminal interface are still supported by the terminal driver by emulation.Note that these old functions cannot control all termios attributes, so theterminal must be in a relatively sane state to avoid problems..SH FILESThe list below shows all devices that Minix and Minix-vmd have.  Not all ofthese devices are configured in by default, as indicated by the numbers(i/j/k, l/m/n) that tell the minimum, default and maximum possible number ofthese devices for Minix (i/j/k) and Minix-vmd (l/m/n)..TP 20.B /dev/consoleSystem console..TP.B /dev/ttyc[1-7]Virtual consoles.  (0/1/7, 0/1/7).TP.BR /dev/logConsole log device..TP.B /dev/tty0[0-3]Serial lines.  (0/2/2, 4/4/4).TP.B /dev/tty[p-w][0-f]Pseudo ttys.  (0/0/64, 1/32/128).TP.B /dev/pty[p-w][0-f]Associated pseudo tty controllers..SH "SEE ALSO".BR stty (1),.BR termios (3),.BR setsid (2),.BR read (2),.BR write (2)..SH BUGSA fair number of flags are not implemented under Minix (yet).  Luckily theyare very limited utility and only apply to RS-232, not to the user interface..SH AUTHORKees J. Bot (kjb@cs.vu.nl)

⌨️ 快捷键说明

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