📄 library_16.html
字号:
Typically, the SUSP character is <KBD>C-z</KBD>.<P>Few applications disable the normal interpretation of the SUSPcharacter. If your program does this, it should provide some othermechanism for the user to stop the job. When the user invokes thismechanism, the program should send a <CODE>SIGTSTP</CODE> signal to theprocess group of the process, not just to the process itself.See section <A HREF="library_21.html#SEC365" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC365">Signaling Another Process</A>.<P><A NAME="IDX1209"></A><A NAME="IDX1210"></A><A NAME="IDX1211"></A><U>Macro:</U> int <B>VDSUSP</B><P>This is the subscript for the DSUSP character in the special controlcharacter array. <CODE><VAR>termios</VAR>.c_cc[VDSUSP]</CODE> holds the characteritself.<P>The DSUSP (suspend) character is recognized only if the implementationsupports job control (see section <A HREF="library_24.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC411">Job Control</A>). It sends a <CODE>SIGTSTP</CODE>signal, like the SUSP character, but not right away--only when theprogram tries to read it as input. Not all systems with job controlsupport DSUSP; only BSD systems.<P>See section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>, for more information about signals.<P>Typically, the DSUSP character is <KBD>C-y</KBD>.<P><H4><A NAME="SEC285" HREF="library_toc.html#SEC285" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC285">Special Characters for Flow Control</A></H4><P>These special characters may be active in either canonical or noncanonicalinput mode, but their use is controlled by the flags <CODE>IXON</CODE> and<CODE>IXOFF</CODE> (see section <A HREF="library_16.html#SEC276" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC276">Input Modes</A>).<P><A NAME="IDX1212"></A><A NAME="IDX1213"></A><U>Macro:</U> int <B>VSTART</B><P>This is the subscript for the START character in the special controlcharacter array. <CODE><VAR>termios</VAR>.c_cc[VSTART]</CODE> holds thecharacter itself.<P>The START character is used to support the <CODE>IXON</CODE> and <CODE>IXOFF</CODE>input modes. If <CODE>IXON</CODE> is set, receiving a START character resumessuspended output; the START character itself is discarded. If<CODE>IXOFF</CODE> is set, the system may also transmit START characters tothe terminal.<P>The usual value for the START character is <KBD>C-q</KBD>. You may not beable to change this value--the hardware may insist on using <KBD>C-q</KBD>regardless of what you specify.<P><A NAME="IDX1214"></A><A NAME="IDX1215"></A><U>Macro:</U> int <B>VSTOP</B><P>This is the subscript for the STOP character in the special controlcharacter array. <CODE><VAR>termios</VAR>.c_cc[VSTOP]</CODE> holds the characteritself.<P>The STOP character is used to support the <CODE>IXON</CODE> and <CODE>IXOFF</CODE>input modes. If <CODE>IXON</CODE> is set, receiving a STOP character causesoutput to be suspended; the STOP character itself is discarded. If<CODE>IXOFF</CODE> is set, the system may also transmit STOP characters to theterminal, to prevent the input queue from overflowing.<P>The usual value for the STOP character is <KBD>C-s</KBD>. You may not beable to change this value--the hardware may insist on using <KBD>C-s</KBD>regardless of what you specify.<P><H4><A NAME="SEC286" HREF="library_toc.html#SEC286" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC286">Other Special Characters</A></H4><P>Here are two additional special characters that are meaningful on BSDsystems.<P><A NAME="IDX1216"></A><A NAME="IDX1217"></A><U>Macro:</U> int <B>VDISCARD</B><P>This is the subscript for the DISCARD character in the special controlcharacter array. <CODE><VAR>termios</VAR>.c_cc[VDISCARD]</CODE> holds the characteritself.<P>The DISCARD character is recognized only when <CODE>IEXTEN</CODE> is set. Itseffect is to toggle the discard-output flag. When this flag is set, allprogram output is discarded. Setting the flag also discards all outputcurrently in the output buffer.<P><A NAME="IDX1218"></A><A NAME="IDX1219"></A><U>Macro:</U> int <B>VSTATUS</B><P>This is the subscript for the STATUS character in the special controlcharacter array. <CODE><VAR>termios</VAR>.c_cc[VSTATUS]</CODE> holds the characteritself.<P>The STATUS character's effect is to print out a status message about howthe current process is running.<P>The STATUS character is recognized only when canonical mode. This is apeculiar design decision, since the STATUS character's meaning hasnothing to do with input, but that's the way it was done.<P><H3><A NAME="SEC287" HREF="library_toc.html#SEC287" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC287">Noncanonical Input</A></H3><P>In noncanonical input mode, the special editing characters such asERASE and KILL are ignored. The system facilities for the user to editinput are disabled in noncanonical mode, so that all input characters(unless they are special for signal or flow-control purposes) are passedto the application program exactly as typed. It is up to theapplication program to give the user ways to edit the input, ifappropriate.<P>Noncanonical mode offers special parameters called MIN and TIME forcontrolling whether and how long to wait for input to be available. Youcan even use them to avoid ever waiting--to return immediately withwhatever input is available, or with no input.<P>The MIN and TIME are stored in elements of the <CODE>c_cc</CODE> array, whichis a member of the <CODE>struct termios</CODE> structure. Each element ofthis array has a particular role, and each element has a symbolicconstant that stands for the index of that element. <CODE>VMIN</CODE> and<CODE>VMAX</CODE> are the names for the indices in the array of the MIN andTIME slots.<P><A NAME="IDX1220"></A><A NAME="IDX1221"></A><U>Macro:</U> int <B>VMIN</B><P>This is the subscript for the MIN slot in the <CODE>c_cc</CODE> array. Thus,<CODE><VAR>termios</VAR>.c_cc[VMIN]</CODE> is the value itself.<P>The MIN slot is only meaningful in noncanonical input mode; itspecifies the minimum number of bytes that must be available in theinput queue in order for <CODE>read</CODE> to return.<P><A NAME="IDX1222"></A><A NAME="IDX1223"></A><U>Macro:</U> int <B>VTIME</B><P>This is the subscript for the TIME slot in the <CODE>c_cc</CODE> array. Thus,<CODE><VAR>termios</VAR>.c_cc[VTIME]</CODE> is the value itself.<P>The TIME slot is only meaningful in noncanonical input mode; itspecifies how long to wait for input before returning, in units of 0.1seconds.<P>The MIN and TIME values interact to determine the criterion for when<CODE>read</CODE> should return; their precise meanings depend on which ofthem are nonzero. There are four possible cases:<P><UL><LI>Both MIN and TIME are zero.<P>In this case, <CODE>read</CODE> always returns immediately with as manycharacters as are available in the queue, up to the number requested.If no input is immediately available, <CODE>read</CODE> returns a value ofzero.<P><LI>MIN is zero but TIME has a nonzero value.<P>In this case, <CODE>read</CODE> waits for time TIME for input to becomeavailable; the availability of a single byte is enough to satisfy theread request and cause <CODE>read</CODE> to return. When it returns, itreturns as many characters as are available, up to the number requested.If no input is available before the timer expires, <CODE>read</CODE> returns avalue of zero.<P><LI>TIME is zero but MIN has a nonzero value.<P>In this case, <CODE>read</CODE> waits until at least MIN bytes are availablein the queue. At that time, <CODE>read</CODE> returns as many characters asare available, up to the number requested. <CODE>read</CODE> can return morethan MIN characters if more than MIN happen to be in the queue.<P><LI>Both TIME and MIN are nonzero.<P>In this case, TIME specifies how long to wait after each input characterto see if more input arrives. <CODE>read</CODE> keeps waiting until eitherMIN bytes have arrived, or TIME elapses with no further input.<P><CODE>read</CODE> can return no input if TIME elapses before the first inputcharacter arrives. <CODE>read</CODE> can return more than MIN characters ifmore than MIN happen to be in the queue.</UL><P>What happens if MIN is 50 and you ask to read just 10 bytes?Normally, <CODE>read</CODE> waits until there are 50 bytes in the buffer (or,more generally, the wait condition described above is satisfied), andthen reads 10 of them, leaving the other 40 buffered in the operatingsystem for a subsequent call to <CODE>read</CODE>.<P><STRONG>Portability note:</STRONG> On some systems, the MIN and TIME slots areactually the same as the EOF and EOL slots. This causes no seriousproblem because the MIN and TIME slots are used only in noncanonicalinput and the EOF and EOL slots are used only in canonical input, but itisn't very clean. The GNU library allocates separate slots for theseuses.<P><A NAME="IDX1224"></A><H2><A NAME="SEC288" HREF="library_toc.html#SEC288" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC288">Line Control Functions</A></H2><P>These functions perform miscellaneous control actions on terminaldevices. As regards terminal access, they are treated like doingoutput: if any of these functions is used by a background process on itscontrolling terminal, normally all processes in the process group aresent a <CODE>SIGTTOU</CODE> signal. The exception is if the calling processitself is ignoring or blocking <CODE>SIGTTOU</CODE> signals, in which case theoperation is performed and no signal is sent. See section <A HREF="library_24.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC411">Job Control</A>.<A NAME="IDX1225"></A><P><A NAME="IDX1226"></A><U>Function:</U> int <B>tcsendbreak</B> <I>(int <VAR>filedes</VAR>, int <VAR>duration</VAR>)</I><P>This function generates a break condition by transmitting a stream ofzero bits on the terminal associated with the file descriptor<VAR>filedes</VAR>. The duration of the break is controlled by the<VAR>duration</VAR> argument. If zero, the duration is between 0.25 and 0.5seconds. The meaning of a nonzero value depends on the operating system.<P>This function does nothing if the terminal is not an asynchronous serialdata port.<P>The return value is normally zero. In the event of an error, a valueof <CODE>-1</CODE> is returned. The following <CODE>errno</CODE> error conditionsare defined for this function:<P><DL COMPACT><DT><CODE>EBADF</CODE><DD>The <VAR>filedes</VAR> is not a valid file descriptor.<P><DT><CODE>ENOTTY</CODE><DD>The <VAR>filedes</VAR> is not associated with a terminal device.</DL><P><A NAME="IDX1227"></A><A NAME="IDX1228"></A><P><A NAME="IDX1229"></A><U>Function:</U> int <B>tcdrain</B> <I>(int <VAR>filedes</VAR>)</I><P>The <CODE>tcdrain</CODE> function waits until all queuedoutput to the terminal <VAR>filedes</VAR> has been transmitted.<P>The return value is normally zero. In the event of an error, a valueof <CODE>-1</CODE> is returned. The following <CODE>errno</CODE> error conditionsare defined for this function:<P><DL COMPACT><DT><CODE>EBADF</CODE><DD>The <VAR>filedes</VAR> is not a valid file descriptor.<P><DT><CODE>ENOTTY</CODE><DD>The <VAR>filedes</VAR> is not associated with a terminal device.<P><DT><CODE>EINTR</CODE><DD>The operation was interrupted by delivery of a signal.See section <A HREF="library_21.html#SEC362" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC362">Primitives Interrupted by Signals</A>.</DL><P><A NAME="IDX1230"></A><A NAME="IDX1231"></A><P><A NAME="IDX1232"></A><U>Function:</U> int <B>tcflush</B> <I>(int <VAR>filedes</VAR>, int <VAR>queue</VAR>)</I><P>The <CODE>tcflush</CODE> function is used to clear the input and/or outputqueues associated with the terminal file <VAR>filedes</VAR>. The <VAR>queue</VAR>argume
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -