tty.4
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 4 代码 · 共 1,190 行 · 第 1/3 页
4
1,190 行
B150 5 150 baudB200 6 200 baudB300 7 300 baudB600 8 600 baudB1200 9 1200 baudB1800 10 1800 baudB2400 11 2400 baudB4800 12 4800 baudB9600 13 9600 baudEXTA 14 External A (19200 baud)EXTB 15 External B (38400 baud).fi.DT.PPCode conversion and line control required forIBM 2741s (134.5 baud)must be implemented by the user'sprogram.The half-duplex line disciplinerequired for the 202 dataset (1200 baud)is not supplied; full-duplex 212 datasets work fine..PPThe.I sg_eraseand.I sg_killfields of the argument structurespecify the erase and kill characters respectively.(Defaults are the number sign (#) and the at sign (@).).PPThe.I sg_flagsfield of the argument structurecontains several bits that determine thesystem's treatment of the terminal:.NXR "sgttyb file" "sg_flags field contents".PP.ta \w'ALLDELAY 'u +\w'0100000 'u.nfALLDELAY 0177400 Delay algorithm selection.spBSDELAY 0100000 Select backspace delays (not implemented):BS0 0BS1 0100000.spVTDELAY 0040000 Select form-feed and vertical-tab delays:FF0 0FF1 0100000.spCRDELAY 0030000 Select carriage-return delays:CR0 0CR1 0010000CR2 0020000CR3 0030000.spTBDELAY 0006000 Select tab delays:TAB0 0TAB1 0002000TAB2 0004000XTABS 0006000.spNLDELAY 0001400 Select new-line delays:NL0 0NL1 0000400NL2 0001000NL3 0001400.spEVENP 0000200 Even parity allowed on input (most terminals)ODDP 0000100 Odd parity allowed on inputRAW 0000040 Raw mode: wake up on all characters, 8-bit interfaceCRMOD 0000020 Map CR into LF; echo LF or CR as CR-LFECHO 0000010 Echo (full duplex)LCASE 0000004 Map uppercase to lowercase on inputCBREAK 0000002 Return each character as soon as typedTANDEM 0000001 Automatic flow control.DT.fi.PPThe delay bits specify how longtransmission 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..PPBackspace delays are ignored but mightbe used for Terminet 300s..PPIf a form-feed/vertical tab delay is specified,it lasts for about two seconds..PPCarriage-return delay type 1 lasts about .08 secondsand is suitable for the Terminet 300.Delay type 2 lasts about .16 seconds and is suitablefor the VT05 and the TI 700.Delay type 3 is suitable for the Concept-100 and pads linesto be at least nine characters at 9600 baud..PPNew-line delay type 1 is dependent on the current columnand is tuned for Teletype Model 37s.Type 2 is useful for the VT05 and is about .10 seconds.Type 3 is is 0 and is unimplemented..PPTab delay type 1 is dependent on the amount of movementand is tuned to the Teletype Model37.Type 3, called XTABS,is not a delay at all but causes tabs to be replacedby the appropriate number of spaces on output..PPThe flags for even and odd parity control parity checking on input andgeneration on output in cooked and CBREAK mode. Even parity is generated onoutput unless ODDP is set and EVENP is clear,in which case odd parity isgenerated. For no parity, set both ODDP and EVENP flags.Input characters with the wrong parity, as determined by EVENP andODDP, are ignored in cooked and CBREAK mode..PPRAWdisables all processing save output flushing with LFLUSHO;full eight bits of input are given as soon asit is available; all eight bits are passed on output.A break condition in the input is reported as a null character.If the input queue overflows in raw mode, it is discarded; this appliesto both new and old drivers..PPCRMOD causes input carriage returns to be turned intonewlines;input of either CR or LF causes LF-CR both tobe echoed(for terminals with a newline function)..PPCBREAK is a sort of half-cooked mode.Programs can read each character as soon as typed, insteadof waiting for a full line;all processing is done, except the input editing:character and word erase and line kill, input reprint,and the special treatment of the backslash (\e) or EOT are disabled..PPTANDEM mode causes the system to producea stop character (default, CTRL/S), whenever the inputqueue is in danger of overflowing, and a start character(default CTRL/Q),when the input queue has drained sufficiently.It is useful for flow control when the ``terminal''is really another computer that understands the conventions..PP.B Basic ioctls \- In addition to the TIOCSETD and TIOCGETD disciplines discussedin \fBLine disciplines\fR,a large number of other.MS ioctl 2calls apply to terminals and have the general form:.PP.B #include <sgtty.h>.PP.B ioctl(fildes, code, arg).br.B struct sgttyb *arg;.PPThe applicable codes are:.NXR "terminal interface" "general ioctl calls".IP TIOCGETP 15Fetch the basic parameters associated with the terminal and storein the pointed-to \fIsgttyb\fR structure..IP TIOCSETPSet the parameters according to the pointed-to \fIsgttyb\fR structure.The interface delays until output is quiescent,and then throws away any unread characters,before changing the modes..IP TIOCSETNSet the parameters like TIOCSETP but do not delay or flush input.Input is not preserved, however, when changing to or from RAW..PPWith the following codes the.I argis ignored..IP TIOCEXCL 15Set \*(lqexclusive-use\*(rq mode:all open calls to this line have been closed. This setting does not preventsuperuser opens of the terminal line. .IP TIOCNXCLTurn off \*(lqexclusive-use\*(rq mode..IP TIOCHPCLWhen the file is closed for the last time,hang up the terminal.This is useful when the line is associatedwith an ACU used to place outgoing calls..PPSetting the pointed-to integer parameter to the following valuesdetermines how TIOCFLUSH functions..IP TIOCFLUSH 15FREAD flushes input queues.FWRITE flushes output queues. Zero (0) flushes both.FREAD and FWRITE are defined in .PN <sys/file.h> ..PPIn cases where arguments are required, they are described; \fIarg\fRshould otherwise be given as zero (0)..IP TIOCSTI 15The argument is the address of a character that the systempretends was typed on the terminal..IP TIOCSBRK 15The break bit is set in the terminal..IP TIOCCBRKThe break bit is cleared..IP TIOCSDTR Data terminal ready is set..IP TIOCCDTRData terminal ready is cleared..IP TIOCSTOPOutput is stopped, as if the ``stop'' character had been typed..IP TIOCSTARTOutput is restarted, as if the ``start'' character had been typed..IP TIOCGPGRP.I arg is the address of a word into which is placed the process groupnumber of the control terminal..IP TIOCSPGRP.I arg is a word (typically a process ID) that becomes the processgroup for the control terminal..IP FIONREADReturns in the long integer whose address is .I arg, the numberof immediately readable characters from the argument unit..PP.B Tchars \- The second structure associated with each terminal specifiescharacters that are special in both the old and new terminal interfaces.The following structure is defined in .PN <sys/ioctl.h> ,which is automatically included in .PN <sgtty.h> :.PP.EXstruct 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) */};.EE.PPThe default values for these characters areCTRL/?, CTRL/\e\|, CTRL/Q, CTRL/S, CTRL/D, and \-1.A character value of \-1eliminates the effect of that character.The.I t_brkccharacter, by default \-1,acts like a newline in that it terminates a ``line'',is echoed, and is passed to the program.The ``stop'' and \*Qstart\*U characters may be the same,to produce a toggle effect.It is probably counterproductive to makeother special characters (including erase and kill)identical.The applicable ioctl calls are:.IP TIOCGETC 12Get the special characters and put them in the specified structure..IP TIOCSETC 12Set the special characters to those given in the structure..PP.B Local mode \- .NXR "terminal interface" "local mode word"The third structure associated with each terminal is a local mode word.The bits of the local mode word are:.sp.nfLCRTBS 0x0001 Backspace on erase, rather than echoing eraseLPRTERA 0x0002 Printing terminal erase modeLCRTERA 0x0004 Erase character echoes as backspace-space-backspaceLTILDE 0x0008 Convert ~ to \` on output (for Hazeltine terminals)LLITOUT 0x0020 Suppress output translationsLTOSTOP 0x0040 Send SIGTTOU for background outputLFLUSHO 0x0080 Output is being flushedLNOHANG 0x0100 Do not send hangup when carrier dropsLAUTOFLOW 0x0200 Hardware responds to flow control characters. (See \fBFlow control\fP.)LCRTKIL 0x0400 BS-space-BS erase entire line on line killLPASS8 0x0800 Allow 8-bit characters in input and outputLCTLECH 0x1000 Echo input control chars as ^X, delete as ^?LPENDIN 0x2000 Retype pending input at next read or input characterLDECCTQ 0x4000 Only CTRL/Q restarts output after CTRL/SLNOFLSH 0x8000 Do not flush output on receipt of suspend or interrupt character.fi.spThe applicable.PN ioctlfunctions are:.IP TIOCLBIS 15.I arg is the address of a mask of bits to be set in the local mode word..IP TIOCLBIC.I arg is the address of a mask ofbits to be cleared in the local mode word..IP TIOCLSET.I arg is the address of a mask to be placed in the local mode word..IP TIOCLGET.I arg is the address of a word into which the current mask is placed..PP.B Window Size \- The fourth structure associated with terminals is the .PN winsizestructure that defines the size of the terminal window.The.PN winsizestructure is defined as follows:.EXstruct winsize { unsigned short ws_row, ws_col; unsigned short ws_xpixel, ws_ypixel; };.EEThe .I ws_row and .I ws_col elements define the window size in terms of the numberof characters per row and column respectively. The .I ws_xpixel and .I ws_ypixeldefine the window size in terms of pixels. The default value is to initializeeach of the elements to zero..spThe applicable.PN ioctlfunctions are:.IP TIOCSWINSZ 15.I arg is the address of a.PN winsizestructure, which defines the new window sizes. This will send a SIGWINCHsignal to notify all members of process group that the window size has changed..IP TIOCGWINSZ 15.I arg is the address of a.PN winsizestructure into which is placedthe current window size settings..PP.B Local special characters \- .NXR "terminal interface" "local special characters"Thefinal structure associated with each terminal is the.PN ltcharsstructure that defines interrupt charactersfor the new terminal driver.Its structure is:.EXstruct ltchars { char t_suspc; /* stop process signal */ char t_dsuspc; /* delayed stop process signal */ char t_rprntc; /* reprint line */ char t_flushc; /* flush output (toggles) */ char t_werasc; /* word erase */ char t_lnextc; /* literal next character */};.EE.PPThe default values for these characters are CTRL/Z, CTRL/Y, CTRL/R, CTRL/O, CTRL/W, and CTRL/V.A value of \-1 disables the character..PPThe applicable ioctl functions are:.IP TIOCSLTC 12.I args is the address of an.PN ltcharsstructure, which defines the new local special characters..IP TIOCGLTC 12.I args is the address of an.PN ltcharsstructure, into which is placedthe current set of local special characters..SH Restrictions.NXR "terminal interface" "restricted"Half-duplex terminals are not supported..SH Files.PN /dev/tty.br.PN /dev/tty*.br.PN /dev/console.SH See Alsocsh(1), stty(1), tset(1), ioctl(2), sigvec(2), stty(3), termio(4), termios(4), getty(8), MAKEDEV(8)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?