📄 xbd_chap11.html
字号:
<p>The foreground/background/orphaned process group check performed by the terminal driver must be repeatedly performed until thecalling process moves into the foreground or until the process group of the calling process becomes orphaned. That is, when theterminal driver determines that the calling process is in the background and should receive a job control signal, it sends theappropriate signal (SIGTTIN or SIGTTOU) to every process in the process group of the calling process and then it allows the callingprocess to immediately receive the signal. The latter is typically performed by blocking the process so that the signal isimmediately noticed. Note, however, that after the process finishes receiving the signal and control is returned to the driver, theterminal driver must re-execute the foreground/background/orphaned process group check. The process may still be in the background,either because it was continued in the background by a job control shell, or because it caught the signal and did nothing.</p><p>The terminal driver repeatedly performs the foreground/background/orphaned process group checks whenever a process is about toaccess the terminal. In the case of <a href="../functions/write.html"><i>write</i>()</a> or the control <i>tc*</i>() functions, the check is performed at the entry of the function. In the case of <a href="../functions/read.html"><i>read</i>()</a>, the check is performed not only at the entry of the function, but also after blockingthe process to wait for input characters (if necessary). That is, once the driver has determined that the process calling the <ahref="../functions/read.html"><i>read</i>()</a> function is in the foreground, it attempts to retrieve characters from the inputqueue. If the queue is empty, it blocks the process waiting for characters. When characters are available and control is returnedto the driver, the terminal driver must return to the repeated foreground/background/orphaned process group check again. Theprocess may have moved from the foreground to the background while it was blocked waiting for input characters.</p><h5><a name="tag_01_11_01_05"></a>Input Processing and Reading Data</h5><p>There is no additional rationale provided for this section.</p><h5><a name="tag_01_11_01_06"></a>Canonical Mode Input Processing</h5><p>The term "character" is intended here. ERASE should erase the last character, not the last byte. In the case of multi-bytecharacters, these two may be different.</p><p>4.3 BSD has a WERASE character that erases the last "word" typed (but not any preceding <blank>s or <tab>s). Aword is defined as a sequence of non- <blank>s, with <tab>s counted as <blank>s. Like ERASE, WERASE does noterase beyond the beginning of the line. This WERASE feature has not been specified in POSIX.1 because it is difficult to define inthe international environment. It is only useful for languages where words are delimited by <blank>s. In some ideographiclanguages, such as Japanese and Chinese, words are not delimited at all. The WERASE character should presumably go back to thebeginning of a sentence in those cases; practically, this means it would not be used much for those languages.</p><p>It should be noted that there is a possible inherent deadlock if the application and implementation conflict on the value of{MAX_CANON}. With ICANON set (if IXOFF is enabled) and more than {MAX_CANON} characters transmitted without a <linefeed>,transmission will be stopped, the <linefeed> (or <carriage-return> when ICRLF is set) will never arrive, and the <ahref="../functions/read.html"><i>read</i>()</a> will never be satisfied.</p><p>An application should not set IXOFF if it is using canonical mode unless it knows that (even in the face of a transmissionerror) the conditions described previously cannot be met or unless it is prepared to deal with the possible deadlock in some otherway, such as timeouts.</p><p>It should also be noted that this can be made to happen in non-canonical mode if the trigger value for sending IXOFF is lessthan VMIN and VTIME is zero.</p><h5><a name="tag_01_11_01_07"></a>Non-Canonical Mode Input Processing</h5><p>Some points to note about MIN and TIME:</p><ol><li><p>The interactions of MIN and TIME are not symmetric. For example, when MIN>0 and TIME=0, TIME has no effect. However, in theopposite case where MIN=0 and TIME>0, both MIN and TIME play a role in that MIN is satisfied with the receipt of a singlecharacter.</p></li><li><p>Also note that in case A (MIN>0, TIME>0), TIME represents an inter-character timer, while in case C (MIN=0, TIME>0),TIME represents a read timer.</p></li></ol><p>These two points highlight the dual purpose of the MIN/TIME feature. Cases A and B, where MIN>0, exist to handle burst-modeactivity (for example, file transfer programs) where a program would like to process at least MIN characters at a time. In case A,the inter-character timer is activated by a user as a safety measure; in case B, it is turned off.</p><p>Cases C and D exist to handle single-character timed transfers. These cases are readily adaptable to screen-based applicationsthat need to know if a character is present in the input queue before refreshing the screen. In case C, the read is timed; in caseD, it is not.</p><p>Another important note is that MIN is always just a minimum. It does not denote a record length. That is, if a program does aread of 20 bytes, MIN is 10, and 25 characters are present, 20 characters are returned to the user. In the special case of MIN=0,this still applies: if more than one character is available, they all will be returned immediately.</p><h5><a name="tag_01_11_01_08"></a>Writing Data and Output Processing</h5><p>There is no additional rationale provided for this section.</p><h5><a name="tag_01_11_01_09"></a>Special Characters</h5><p>There is no additional rationale provided for this section.</p><h5><a name="tag_01_11_01_10"></a>Modem Disconnect</h5><p>There is no additional rationale provided for this section.</p><h5><a name="tag_01_11_01_11"></a>Closing a Terminal Device File</h5><p>IEEE Std 1003.1-2001 does not specify that a <a href="../functions/close.html"><i>close</i>()</a> on a terminal devicefile include the equivalent of a call to <i>tcflow</i>( <i>fd</i>,TCOON).</p><p>An implementation that discards output at the time <a href="../functions/close.html"><i>close</i>()</a> is called afterreporting the return value to the <a href="../functions/write.html"><i>write</i>()</a> call that data was written does not conformwith IEEE Std 1003.1-2001. An application has functions such as <a href="../functions/tcdrain.html"><i>tcdrain</i>()</a>,<a href="../functions/tcflush.html"><i>tcflush</i>()</a>, and <a href="../functions/tcflow.html"><i>tcflow</i>()</a> available toobtain the detailed behavior it requires with respect to flushing of output.</p><p>At the time of the last close on a terminal device, an application relinquishes any ability to exert flow control via <a href="../functions/tcflow.html"><i>tcflow</i>()</a>.</p><h4><a name="tag_01_11_02"></a>Parameters that Can be Set</h4><h5><a name="tag_01_11_02_01"></a>The termios Structure</h5><p>This structure is part of an interface that, in general, retains the historic grouping of flags. Although a more optimalstructure for implementations may be possible, the degree of change to applications would be significantly larger.</p><h5><a name="tag_01_11_02_02"></a>Input Modes</h5><p>Some historical implementations treated a long break as multiple events, as many as one per character time. The wording inPOSIX.1 explicitly prohibits this.</p><p>Although the ISTRIP flag is normally superfluous with today's terminal hardware and software, it is historically supported.Therefore, applications may be using ISTRIP, and there is no technical problem with supporting this flag. Also, applications maywish to receive only 7-bit input bytes and may not be connected directly to the hardware terminal device (for example, when aconnection traverses a network).</p><p>Also, there is no requirement in general that the terminal device ensures that high-order bits beyond the specified charactersize are cleared. ISTRIP provides this function for 7-bit characters, which are common.</p><p>In dealing with multi-byte characters, the consequences of a parity error in such a character, or in an escape sequenceaffecting the current character set, are beyond the scope of POSIX.1 and are best dealt with by the application processing themulti-byte characters.</p><h5><a name="tag_01_11_02_03"></a>Output Modes</h5><p>POSIX.1 does not describe postprocessing of output to a terminal or detailed control of that from a conforming application.(That is, translation of <newline> to <carriage-return> followed by <linefeed> or <tab> processing.) Thereis nothing that a conforming application should do to its output for a terminal because that would require knowledge of theoperation of the terminal. It is the responsibility of the operating system to provide postprocessing appropriate to the outputdevice, whether it is a terminal or some other type of device.</p><p>Extensions to POSIX.1 to control the type of postprocessing already exist and are expected to continue into the future. Thecontrol of these features is primarily to adjust the interface between the system and the terminal device so the output appears onthe display correctly. This should be set up before use by any application.</p><p>In general, both the input and output modes should not be set absolutely, but rather modified from the inherited state.</p><h5><a name="tag_01_11_02_04"></a>Control Modes</h5><p>This section could be misread that the symbol "CSIZE" is a title in the <b>termios</b> <i>c_cflag</i> field. Although it doesserve that function, it is also a required symbol, as a literal reading of POSIX.1 (and the caveats about typography) wouldindicate.</p><h5><a name="tag_01_11_02_05"></a>Local Modes</h5><p>Non-canonical mode is provided to allow fast bursts of input to be read efficiently while still allowing single-characterinput.</p><p>The ECHONL function historically has been in many implementations. Since there seems to be no technical problem with supportingECHONL, it is included in POSIX.1 to increase consensus.</p><p>The alternate behavior possible when ECHOK or ECHOE are specified with ICANON is permitted as a compromise depending on what theactual terminal hardware can do. Erasing characters and lines is preferred, but is not always possible.</p><h5><a name="tag_01_11_02_06"></a>Special Control Characters</h5><p>Permitting VMIN and VTIME to overlap with VEOF and VEOL was a compromise for historical implementations. Only whenbackwards-compatibility of object code is a serious concern to an implementor should an implementation continue this practice.Correct applications that work with the overlap (at the source level) should also work if it is not present, but not thereverse.</p><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -