⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsh_chap02_04.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!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>System Interfaces Chapter 2</title></head><body><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition</font></center><hr size="2" noshade><h3><a name="tag_02_04">   2.4 </a>Signal Concepts</h3><h4><a name="tag_02_04_01">  2.4.1 </a>Signal Generation and Delivery</h4><p>A signal is said to be ``generated'' for (or sent to) a process or thread when the event that causes the signal first occurs.Examples of such events include detection of hardware faults, timer expiration, <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;signalsgenerated via the <b>sigevent</b> structure <img src="../images/opt-end.gif" alt="[Option End]" border="0"> and terminal activity,as well as invocations of the <a href="../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"> &nbsp;and <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a> functions. <img src="../images/opt-end.gif" alt="[Option End]" border="0"> Insome circumstances, the same event generates signals for multiple processes.</p><p>At the time of generation, a determination shall be made whether the signal has been generated for the process or for a specificthread within the process. Signals which are generated by some action attributable to a particular thread, such as a hardwarefault, shall be generated for the thread that caused the signal to be generated. Signals that are generated in association with aprocess ID or process group ID or an asynchronous event, such as terminal activity, shall be generated for the process.</p><p>Each process has an action to be taken in response to each signal defined by the system (see <a href="#tag_02_04_03">SignalActions</a> ). A signal is said to be ``delivered'' to a process when the appropriate action for the process and signal is taken. Asignal is said to be ``accepted'' by a process when the signal is selected and returned by one of the <a href="../functions/sigwait.html"><i>sigwait</i>()</a> functions.</p><p>During the time between the generation of a signal and its delivery or acceptance, the signal is said to be ``pending''.Ordinarily, this interval cannot be detected by an application. However, a signal can be ``blocked'' from delivery to a thread. Ifthe action associated with a blocked signal is anything other than to ignore the signal, and if that signal is generated for thethread, the signal shall remain pending until it is unblocked, it is accepted when it is selected and returned by a call to the <ahref="../functions/sigwait.html"><i>sigwait</i>()</a> function, or the action associated with it is set to ignore the signal.Signals generated for the process shall be delivered to exactly one of those threads within the process which is in a call to a <ahref="../functions/sigwait.html"><i>sigwait</i>()</a> function selecting that signal or has not blocked delivery of the signal. Ifthere are no threads in a call to a <a href="../functions/sigwait.html"><i>sigwait</i>()</a> function selecting that signal, and ifall threads within the process block delivery of the signal, the signal shall remain pending on the process until a thread calls a<a href="../functions/sigwait.html"><i>sigwait</i>()</a> function selecting that signal, a thread unblocks delivery of the signal,or the action associated with the signal is set to ignore the signal. If the action associated with a blocked signal is to ignorethe signal and if that signal is generated for the process, it is unspecified whether the signal is discarded immediately upongeneration or remains pending.</p><p>Each thread has a ``signal mask'' that defines the set of signals currently blocked from delivery to it. The signal mask for athread shall be initialized from that of its parent or creating thread, or from the corresponding thread in the parent process ifthe thread was created as the result of a call to <a href="../functions/fork.html"><i>fork</i>()</a>. The <a href="../functions/pthread_sigmask.html"><i>pthread_sigmask</i>()</a>, <a href="../functions/sigaction.html"><i>sigaction</i>()</a>, <ahref="../functions/sigprocmask.html"><i>sigprocmask</i>()</a>, and <a href="../functions/sigsuspend.html"><i>sigsuspend</i>()</a>functions control the manipulation of the signal mask.</p><p>The determination of which action is taken in response to a signal is made at the time the signal is delivered, allowing for anychanges since the time of generation. This determination is independent of the means by which the signal was originally generated.If a subsequent occurrence of a pending signal is generated, it is implementation-defined as to whether the signal is delivered oraccepted more than once <sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;in circumstances other than those in which queuing is required under the Realtime SignalsExtension option. The order in which multiple, simultaneously pending signals outside the range SIGRTMIN to SIGRTMAX are deliveredto or accepted by a process is unspecified. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>When any stop signal (SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU) is generated for a process, any pending SIGCONT signals for thatprocess shall be discarded. Conversely, when SIGCONT is generated for a process, all pending stop signals for that process shall bediscarded. When SIGCONT is generated for a process that is stopped, the process shall be continued, even if the SIGCONT signal isblocked or ignored. If SIGCONT is blocked and not ignored, it shall remain pending until it is either unblocked or a stop signal isgenerated for the process.</p><p>An implementation shall document any condition not specified by this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 under which theimplementation generates signals.</p><h4><a name="tag_02_04_02">  2.4.2 </a>Realtime Signal Generation and Delivery</h4><p><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">This section describes extensions to support realtime signal generation and delivery. This functionality is dependent on support ofthe Realtime Signals Extension option (and the rest of this section is not further marked for this option). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>Some signal-generating functions, such as high-resolution timer expiration, asynchronous I/O completion, interprocess messagearrival, and the <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a> function, support the specification of anapplication-defined value, either explicitly as a parameter to the function or in a <b>sigevent</b> structure parameter. The<b>sigevent</b> structure is defined in <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> and contains at least thefollowing 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>sigev_notify</i></p></td><td align="left"><p class="tent">Notification type.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>int</b></p></td><td align="left"><p class="tent"><i>sigev_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>union sigval</b></p></td><td align="left"><p class="tent"><i>sigev_value</i></p></td><td align="left"><p class="tent">Signal value.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>void(*)(unsigned sigval)</b></p></td><td align="left"><p class="tent"><i>sigev_notify_function</i></p></td><td align="left"><p class="tent">Notification function.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>(pthread_attr_t*)</b></p></td><td align="left"><p class="tent"><i>sigev_notify_attributes</i></p></td><td align="left"><p class="tent">Notification attributes.</p></td></tr></table></center><p>The <i>sigev_notify</i> member specifies the notification mechanism to use when an asynchronous event occurs. This volume ofIEEE&nbsp;Std&nbsp;1003.1-2001 defines the following values for the <i>sigev_notify</i> member:</p><dl compact><dt>SIGEV_NONE</dt><dd>No asynchronous notification shall be delivered when the event of interest occurs.</dd><dt>SIGEV_SIGNAL</dt><dd>The signal specified in <i>sigev_signo</i> shall be generated for the process when the event of interest occurs. If theimplementation supports the Realtime Signals Extension option and if the SA_SIGINFO flag is set for that signal number, then thesignal shall be queued to the process and the value specified in <i>sigev_value</i> shall be the <i>si_value</i> component of thegenerated signal. If SA_SIGINFO is not set for that signal number, it is unspecified whether the signal is queued and what value,if any, is sent.</dd><dt>SIGEV_THREAD</dt><dd>A notification function shall be called to perform notification.</dd></dl><p>An implementation may define additional notification mechanisms.</p><p>The <i>sigev_signo</i> member specifies the signal to be generated. The <i>sigev_value</i> member is the application-definedvalue to be passed to the signal-catching function at the time of the signal delivery or to be returned at signal acceptance as the<i>si_value</i> member of the <b>siginfo_t</b> structure.</p><p>The <b>sigval</b> union is defined in <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> and contains at least thefollowing 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>sival_int</i></p></td><td align="left">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -