📄 fd_zero.html
字号:
<p><i>FD_ISSET</i>(<i>fd</i>, <i>fdsetp</i>) shall evaluate to non-zero if the file descriptor <i>fd</i> is a member of the setpointed to by <i>fdsetp</i>, and shall evaluate to zero otherwise.</p><p><i>FD_SET</i>(<i>fd</i>, <i>fdsetp</i>) shall add the file descriptor <i>fd</i> to the set pointed to by <i>fdsetp</i>. If thefile descriptor <i>fd</i> is already in this set, there shall be no effect on the set, nor will an error be returned.</p><p><i>FD_ZERO</i>(<i>fdsetp</i>) shall initialize the descriptor set pointed to by <i>fdsetp</i> to the null set. No error isreturned if the set is not empty at the time <i>FD_ZERO</i>() is invoked.</p><p>The behavior of these macros is undefined if the <i>fd</i> argument is less than 0 or greater than or equal to FD_SETSIZE, or if<i>fd</i> is not a valid file descriptor, or if any of the arguments are expressions with side effects.</p></blockquote><h4><a name="tag_03_485_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, the <i>pselect</i>() and <i>select</i>() functions shall return the total number of bits set in thebit masks. Otherwise, -1 shall be returned, and <i>errno</i> shall be set to indicate the error.</p><p><i>FD_CLR</i>(), <i>FD_SET</i>(), and <i>FD_ZERO</i>() do not return a value. <i>FD_ISSET</i>() shall return a non-zero value ifthe bit for the file descriptor <i>fd</i> is set in the file descriptor set pointed to by <i>fdset</i>, and 0 otherwise.</p></blockquote><h4><a name="tag_03_485_05"></a>ERRORS</h4><blockquote><p>Under the following conditions, <i>pselect</i>() and <i>select</i>() shall fail and set <i>errno</i> to:</p><dl compact><dt>[EBADF]</dt><dd>One or more of the file descriptor sets specified a file descriptor that is not a valid open file descriptor.</dd><dt>[EINTR]</dt><dd>The function was interrupted before any of the selected events occurred and before the timeout interval expired. <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If SA_RESTART has been set for the interrupting signal, it is implementation-defined whether the function restarts or returns with[EINTR]. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd><dt>[EINVAL]</dt><dd>An invalid timeout interval was specified.</dd><dt>[EINVAL]</dt><dd>The <i>nfds</i> argument is less than 0 or greater than FD_SETSIZE.</dd><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('XSR')">XSR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">One of the specified file descriptors refers to a STREAM or multiplexer that is linked (directly or indirectly) downstream from amultiplexer. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_485_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_485_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_485_08"></a>RATIONALE</h4><blockquote><p>In previous versions of the Single UNIX Specification, the <i>select</i>() function was defined in the <a href="../basedefs/sys/time.h.html"><i><sys/time.h></i></a> header. This is now changed to <a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a>. The rationale for this change was as follows: the introduction ofthe <i>pselect</i>() function included the <a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a> header and the<a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a> header defines all the related definitions for the<i>pselect</i>() and <i>select</i>() functions. Backwards-compatibility to existing XSI implementations is handled by allowing <ahref="../basedefs/sys/time.h.html"><i><sys/time.h></i></a> to include <a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a>.</p></blockquote><h4><a name="tag_03_485_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_485_10"></a>SEE ALSO</h4><blockquote><p><a href="accept.html"><i>accept</i>()</a>, <a href="alarm.html"><i>alarm</i>()</a>, <a href="connect.html"><i>connect</i>()</a>, <a href="fcntl.html"><i>fcntl</i>()</a>, <a href="poll.html"><i>poll</i>()</a>, <a href="read.html"><i>read</i>()</a>, <a href="recvmsg.html"><i>recvmsg</i>()</a>, <a href="sendmsg.html"><i>sendmsg</i>()</a>, <ahref="setitimer.html"><i>setitimer</i>()</a>, <a href="ualarm.html"><i>ualarm</i>()</a>, <a href="write.html"><i>write</i>()</a>, the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a>, <a href="../basedefs/sys/time.h.html"><i><sys/time.h></i></a></p></blockquote><h4><a name="tag_03_485_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_485_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p><p>In the ERRORS section, the text has been changed to indicate that [EINVAL] is returned when <i>nfds</i> is less than 0 orgreater than FD_SETSIZE. It previously stated less than 0, or greater than or equal to FD_SETSIZE.</p><p>Text about <i>timeout</i> is moved from the APPLICATION USAGE section to the DESCRIPTION.</p></blockquote><h4><a name="tag_03_485_13"></a>Issue 6</h4><blockquote><p>The Open Group Corrigendum U026/6 is applied, changing the occurrences of <i>readfs</i> and <i>writefs</i> in the<i>select</i>() DESCRIPTION to be <i>readfds</i> and <i>writefds</i>.</p><p>Text referring to sockets is added to the DESCRIPTION.</p><p>The DESCRIPTION and ERRORS sections are updated so that references to STREAMS are marked as part of the XSI STREAMS OptionGroup.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>These functions are now mandatory.</p></li></ul><p>The <i>pselect</i>() function is added for alignment with IEEE Std 1003.1g-2000 and additional detail related tosockets semantics is added to the DESCRIPTION.</p><p>The <i>select</i>() function now requires inclusion of <a href="../basedefs/sys/select.h.html"><i><sys/select.h></i></a>.</p><p>The <b>restrict</b> keyword is added to the <i>select</i>() prototype for alignment with the ISO/IEC 9899:1999standard.</p><p>IEEE Std 1003.1-2001/Cor 2-2004, item XSH/TC2/D6/70 is applied, updating the DESCRIPTION to reference the signalmask in terms of the calling thread rather than the process.</p></blockquote><div class="box"><em>End of informative text.</em></div><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 + -