📄 xsh_chap02_04.html
字号:
<p class="tent">Integer signal value.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>void*</b></p></td><td align="left"><p class="tent"><i>sival_ptr</i></p></td><td align="left"><p class="tent">Pointer signal value.</p></td></tr></table></center><p>The <i>sival_int</i> member shall be used when the application-defined value is of type <b>int</b>; the <i>sival_ptr</i> membershall be used when the application-defined value is a pointer.</p><p>When a signal is generated by the <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a> function or any signal-generatingfunction that supports the specification of an application-defined value, the signal shall be marked pending and, if the SA_SIGINFOflag is set for that signal, the signal shall be queued to the process along with the application-specified signal value. Multipleoccurrences of signals so generated are queued in FIFO order. It is unspecified whether signals so generated are queued when theSA_SIGINFO flag is not set for that signal.</p><p>Signals generated by the <a href="../functions/kill.html"><i>kill</i>()</a> function or other events that cause signals tooccur, such as detection of hardware faults, <a href="../functions/alarm.html"><i>alarm</i>()</a> timer expiration, or terminalactivity, and for which the implementation does not support queuing, shall have no effect on signals already queued for the samesignal number.</p><p>When multiple unblocked signals, all in the range SIGRTMIN to SIGRTMAX, are pending, the behavior shall be as if theimplementation delivers the pending unblocked signal with the lowest signal number within that range. No other ordering of signaldelivery is specified.</p><p>If, when a pending signal is delivered, there are additional signals queued to that signal number, the signal shall remainpending. Otherwise, the pending indication shall be reset.</p><p>Multi-threaded programs can use an alternate event notification mechanism. When a notification is processed, and the<i>sigev_notify</i> member of the <b>sigevent</b> structure has the value SIGEV_THREAD, the function <i>sigev_notify_function</i>is called with parameter <i>sigev_value</i>.</p><p>The function shall be executed in an environment as if it were the <i>start_routine</i> for a newly created thread with threadattributes specified by <i>sigev_notify_attributes</i>. If <i>sigev_notify_attributes</i> is NULL, the behavior shall be as if thethread were created with the <i>detachstate</i> attribute set to PTHREAD_CREATE_DETACHED. Supplying an attributes structure with a<i>detachstate</i> attribute of PTHREAD_CREATE_JOINABLE results in undefined behavior. The signal mask of this thread isimplementation-defined.</p><h4><a name="tag_02_04_03"> 2.4.3 </a>Signal Actions</h4><p>There are three types of action that can be associated with a signal: SIG_DFL, SIG_IGN, or a pointer to a function. Initially,all signals shall be set to SIG_DFL or SIG_IGN prior to entry of the <i>main</i>() routine (see the <i><a href="../functions/exec.html">exec</a></i> functions). The actions prescribed by these values are as follows:</p><dl compact><dt>SIG_DFL</dt><dd>Signal-specific default action. <p>The default actions for the signals defined in this volume of IEEE Std 1003.1-2001 are specified under <a href="../basedefs/signal.h.html"><i><signal.h></i></a>. <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> If the Realtime Signals Extension option is supported, the defaultactions for the realtime signals in the range SIGRTMIN to SIGRTMAX shall be to terminate the process abnormally. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>If the default action is to stop the process, the execution of that process is temporarily suspended. When a process stops, aSIGCHLD signal shall be generated for its parent process, unless the parent process has set the SA_NOCLDSTOP flag. While a processis stopped, any additional signals that are sent to the process shall not be delivered until the process is continued, exceptSIGKILL which always terminates the receiving process. A process that is a member of an orphaned process group shall not be allowedto stop in response to the SIGTSTP, SIGTTIN, or SIGTTOU signals. In cases where delivery of one of these signals would stop such aprocess, the signal shall be discarded.</p><p>Setting a signal action to SIG_DFL for a signal that is pending, and whose default action is to ignore the signal (for example,SIGCHLD), shall cause the pending signal to be discarded, whether or not it is blocked. <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> If theRealtime Signals Extension option is supported, any queued values pending shall be discarded and the resources used to queue themshall be released and returned to the system for other use. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The default action for SIGCONT is to resume execution at the point where the process was stopped, after first handling anypending unblocked signals.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">When a stopped process is continued, a SIGCHLD signal may be generated for its parent process, unless the parent process has setthe SA_NOCLDSTOP flag. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd><dt>SIG_IGN</dt><dd>Ignore signal. <p>Delivery of the signal shall have no effect on the process. The behavior of a process is undefined after it ignores a SIGFPE,SIGILL, SIGSEGV, <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> or SIGBUS <img src="../images/opt-end.gif" alt="[Option End]" border="0"> signal that was not generated by <ahref="../functions/kill.html"><i>kill</i>()</a>, <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a>, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> or <a href="../functions/raise.html"><i>raise</i>()</a>.</p><p>The system shall not allow the action for the signals SIGKILL or SIGSTOP to be set to SIG_IGN.</p><p>Setting a signal action to SIG_IGN for a signal that is pending shall cause the pending signal to be discarded, whether or notit is blocked.</p><p>If a process sets the action for the SIGCHLD signal to SIG_IGN, the behavior is unspecified, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> except asspecified below.</p><p>If the action for the SIGCHLD signal is set to SIG_IGN, child processes of the calling processes shall not be transformed intozombie processes when they terminate. If the calling process subsequently waits for its children, and the process has nounwaited-for children that were transformed into zombie processes, it shall block until all of its children terminate, and <a href="../functions/wait.html"><i>wait</i>()</a>, <a href="../functions/waitid.html"><i>waitid</i>()</a>, and <a href="../functions/waitpid.html"><i>waitpid</i>()</a> shall fail and set <i>errno</i> to [ECHILD]. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If the Realtime Signals Extension option is supported, any queued values pending shall be discarded and the resources used to queuethem shall be released and made available to queue other signals. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd><dt><i>pointer to a function</i></dt><dd>Catch signal. <p>On delivery of the signal, the receiving process is to execute the signal-catching function at the specified address. Afterreturning from the signal-catching function, the receiving process shall resume execution at the point at which it wasinterrupted.</p><p>If the SA_SIGINFO flag for the signal is cleared, the signal-catching function shall be entered as a C-language function call asfollows:</p><pre><tt>void</tt> <i>func</i><tt>(int</tt> <i>signo</i><tt>);</tt></pre><p><sup>[<a href="javascript:open_code('XSI')">XSI|RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> If the SA_SIGINFO flag for the signal is set, the signal-catching function shall be entered as a C-language function call asfollows:</p><pre><tt>void</tt> <i>func</i><tt>(int</tt> <i>signo</i><tt>, siginfo_t *</tt><i>info</i><tt>, void *</tt><i>context</i><tt>);</tt></pre><p>where <i>func</i> is the specified signal-catching function, <i>signo</i> is the signal number of the signal being delivered,and <i>info</i> is a pointer to a <b>siginfo_t</b> structure defined in <a href="../basedefs/signal.h.html"><i><signal.h></i></a> containing at least the following members:</p><center><table border="1" cellpadding="3" align="center"><tr valign="top"><th align="center"><p class="tent"><b>Member Type</b></p></th><th align="center"><p class="tent"><b>Member Name</b></p></th><th align="center"><p class="tent"><b>Description</b></p></th></tr><tr valign="top"><td align="left"><p class="tent"><b>int</b></p></td><td align="left"><p class="tent"><i>si_signo</i></p></td><td align="left"><p class="tent">Signal number.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>int</b></p></td><td align="left"><p class="tent"><i>si_code</i></p></td><td align="left"><p class="tent">Cause of the signal.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>union sigval</b></p></td><td align="left"><p class="tent"><i>si_value</i></p></td><td align="left"><p class="tent">Signal value.</p></td></tr></table></center><p>The <i>si_signo</i> member shall contain the signal number. This shall be the same as the <i>signo</i> parameter. The<i>si_code</i> member shall contain a code identifying the cause of the signal. The following values are defined for<i>si_code</i>:</p><dl compact><dt>SI_USER</dt><dd>The signal was sent by the <a href="../functions/kill.html"><i>kill</i>()</a> function. The implementation may set<i>si_code</i> to SI_USER if the signal was sent by the <a href="../functions/raise.html"><i>raise</i>()</a> or <a href="../functions/abort.html"><i>abort</i>()</a> functions or any similar functions provided as implementation extensions. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>SI_QUEUE</dt><dd><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The signal was sent by the <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a> function. <img src="../images/opt-end.gif"alt="[Option End]" border="0"></dd><dt>SI_TIMER</dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -