sigwait.html
来自「posix标准英文,html格式」· HTML 代码 · 共 165 行
HTML
165 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>sigwait</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="sigwait"></a> <a name="tag_03_700"></a><!-- sigwait --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright © 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_700_01"></a>NAME</h4><blockquote>sigwait - wait for queued signals</blockquote><h4><a name="tag_03_700_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include <<a href="../basedefs/signal.h.html">signal.h</a>><br><br> int sigwait(const sigset_t *restrict</tt> <i>set</i><tt>, int *restrict</tt> <i>sig</i><tt>); <img src="../images/opt-end.gif"alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_700_03"></a>DESCRIPTION</h4><blockquote><p>The <i>sigwait</i>() function shall select a pending signal from <i>set</i>, atomically clear it from the system's set ofpending signals, and return that signal number in the location referenced by <i>sig</i>. If prior to the call to <i>sigwait</i>()there are multiple pending instances of a single signal number, it is implementation-defined whether upon successful return thereare any remaining pending signals for that signal number. <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> If the implementation supports queued signals and there aremultiple signals queued for the signal number selected, the first such queued signal shall cause a return from <i>sigwait</i>() andthe remainder shall remain queued. <img src="../images/opt-end.gif" alt="[Option End]" border="0"> If no signal in <i>set</i> ispending at the time of the call, the thread shall be suspended until one or more becomes pending. The signals defined by <i>set</i>shall have been blocked at the time of the call to <i>sigwait</i>(); otherwise, the behavior is undefined. The effect of<i>sigwait</i>() on the signal actions for the signals in <i>set</i> is unspecified.</p><p>If more than one thread is using <i>sigwait</i>() to wait for the same signal, no more than one of these threads shall returnfrom <i>sigwait</i>() with the signal number. If more than a single thread is blocked in <i>sigwait</i>() for a signal when thatsignal is generated for the process, it is unspecified which of the waiting threads returns from <i>sigwait</i>(). If the signal isgenerated for a specific thread, as by <a href="../functions/pthread_kill.html"><i>pthread_kill</i>()</a>, only that thread shallreturn.</p><p><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Should any of the multiple pending signals in the range SIGRTMIN to SIGRTMAX be selected, it shall be the lowest numbered one. Theselection order between realtime and non-realtime signals, or between multiple pending non-realtime signals, is unspecified. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_700_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>sigwait</i>() shall store the signal number of the received signal at the location referenced by<i>sig</i> and return zero. Otherwise, an error number shall be returned to indicate the error.</p></blockquote><h4><a name="tag_03_700_05"></a>ERRORS</h4><blockquote><p>The <i>sigwait</i>() function may fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The <i>set</i> argument contains an invalid or unsupported signal number.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_700_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_700_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_700_08"></a>RATIONALE</h4><blockquote><p>To provide a convenient way for a thread to wait for a signal, this volume of IEEE Std 1003.1-2001 provides the<i>sigwait</i>() function. For most cases where a thread has to wait for a signal, the <i>sigwait</i>() function should be quiteconvenient, efficient, and adequate.</p><p>However, requests were made for a lower-level primitive than <i>sigwait</i>() and for semaphores that could be used by threads.After some consideration, threads were allowed to use semaphores and <a href="../functions/sem_post.html"><i>sem_post</i>()</a> wasdefined to be async-signal and async-cancel-safe.</p><p>In summary, when it is necessary for code run in response to an asynchronous signal to notify a thread, <i>sigwait</i>() shouldbe used to handle the signal. Alternatively, if the implementation provides semaphores, they also can be used, either following<i>sigwait</i>() or from within a signal handling routine previously registered with <a href="../functions/sigaction.html"><i>sigaction</i>()</a>.</p></blockquote><h4><a name="tag_03_700_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_700_10"></a>SEE ALSO</h4><blockquote><p><a href="xsh_chap02_04.html#tag_02_04"><i>Signal Concepts</i></a>, <a href="xsh_chap02_08.html#tag_02_08_01"><i>RealtimeSignals</i></a>, <a href="pause.html"><i>pause</i>()</a>, <a href="pthread_sigmask.html"><i>pthread_sigmask</i>()</a>, <a href="sigaction.html"><i>sigaction</i>()</a>, <a href="sigpending.html"><i>sigpending</i>()</a>, <a href="sigsuspend.html"><i>sigsuspend</i>()</a>, <a href="sigwaitinfo.html"><i>sigwaitinfo</i>()</a>, the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/signal.h.html"><i><signal.h></i></a>, <a href="../basedefs/time.h.html"><i><time.h></i></a></p></blockquote><h4><a name="tag_03_700_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5. Included for alignment with the POSIX Realtime Extension and the POSIX Threads Extension.</p></blockquote><h4><a name="tag_03_700_12"></a>Issue 6</h4><blockquote><p>The <b>restrict</b> keyword is added to the <i>sigwait</i>() prototype for alignment with the ISO/IEC 9899:1999standard.</p><p>IEEE Std 1003.1-2001/Cor 2-2004, item XSH/TC2/D6/131 is applied, updating the DESCRIPTION section to state thatif more than a single thread is blocked in <i>sigwait</i>(), it is unspecified which of the waiting threads returns, and that if asignal is generated for a specific thread only that thread shall return.</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 + =
减小字号Ctrl + -
显示快捷键?