Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/sigaction.html
2024-02-19 00:21:47 -05:00

535 lines
30 KiB
HTML

<!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 The Open Group, All Rights Reserved -->
<title>sigaction</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="sigaction"></a> <a name="tag_03_680"></a><!-- sigaction -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_680_01"></a>NAME</h4>
<blockquote>sigaction - examine and change a signal action</blockquote>
<h4><a name="tag_03_680_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 &lt;<a href="../basedefs/signal.h.html">signal.h</a>&gt;<br>
<br>
int sigaction(int</tt> <i>sig</i><tt>, const struct sigaction *restrict</tt> <i>act</i><tt>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct sigaction *restrict</tt> <i>oact</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_680_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>sigaction</i>() function allows the calling process to examine and/or specify the action to be associated with a specific
signal. The argument <i>sig</i> specifies the signal; acceptable values are defined in <a href=
"../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a>.</p>
<p>The structure <b>sigaction</b>, used to describe an action to be taken, is defined in the <a href=
"../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> header to include 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>void(*) (int)</b></p>
</td>
<td align="left">
<p class="tent"><i>sa_handler</i></p>
</td>
<td align="left">
<p class="tent">SIG_DFL, SIG_IGN, or pointer to a function.</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent"><b>sigset_t</b></p>
</td>
<td align="left">
<p class="tent"><i>sa_mask</i></p>
</td>
<td align="left">
<p class="tent">Additional set of signals to be blocked during execution of signal-catching function.</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent"><b>int</b></p>
</td>
<td align="left">
<p class="tent"><i>sa_flags</i></p>
</td>
<td align="left">
<p class="tent">Special flags to affect behavior of signal.</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent"><b>void(*) (int,</b></p>
</td>
<td align="left">
<p class="tent"><i>&nbsp;</i></p>
</td>
<td align="left">
<p class="tent">&nbsp;</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent"><b>&nbsp;&nbsp;siginfo_t *, void *)</b></p>
</td>
<td align="left">
<p class="tent"><i>sa_sigaction</i></p>
</td>
<td align="left">
<p class="tent">Signal-catching function.</p>
</td>
</tr>
</table>
</center>
<p>The storage occupied by <i>sa_handler</i> and <i>sa_sigaction</i> may overlap, and a conforming application shall not use both
simultaneously.</p>
<p>If the argument <i>act</i> is not a null pointer, it points to a structure specifying the action to be associated with the
specified signal. If the argument <i>oact</i> is not a null pointer, the action previously associated with the signal is stored in
the location pointed to by the argument <i>oact</i>. If the argument <i>act</i> is a null pointer, signal handling is unchanged;
thus, the call can be used to enquire about the current handling of a given signal. The SIGKILL and SIGSTOP signals shall not be
added to the signal mask using this mechanism; this restriction shall be enforced by the system without causing an error to be
indicated.</p>
<p>If the SA_SIGINFO flag (see below) is cleared in the <i>sa_flags</i> field of the <b>sigaction</b> structure, the
<i>sa_handler</i> field identifies the action to be associated with the specified signal. <sup>[<a href=
"javascript:open_code('XSI')">XSI|RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;If the
SA_SIGINFO flag is set in the <i>sa_flags</i> field, and the implementation supports the Realtime Signals Extension option or the
XSI Extension option, the <i>sa_sigaction</i> field specifies a signal-catching function. <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"> If the SA_SIGINFO bit is cleared and the <i>sa_handler</i> field specifies a signal-catching function,
or if the SA_SIGINFO bit is set, the <i>sa_mask</i> field identifies a set of signals that shall be added to the signal mask of the
thread before the signal-catching function is invoked. If the <i>sa_handler</i> field specifies a signal-catching function, the
<i>sa_mask</i> field identifies a set of signals that shall be added to the process' signal mask before the signal-catching
function is invoked.</p>
<p>The <i>sa_flags</i> field can be used to modify the behavior of the specified signal.</p>
<p>The following flags, defined in the <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> header, can be set in
<i>sa_flags</i>:</p>
<dl compact>
<dt>SA_NOCLDSTOP</dt>
<dd>Do not generate SIGCHLD when children stop <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src=
"../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;or stopped children continue. <img src="../images/opt-end.gif"
alt="[Option End]" border="0">
<p>If <i>sig</i> is SIGCHLD and the SA_NOCLDSTOP flag is not set in <i>sa_flags</i>, and the implementation supports the SIGCHLD
signal, then a SIGCHLD signal shall be generated for the calling process whenever any of its child processes stop <sup>[<a href=
"javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and a
SIGCHLD signal may be generated for the calling process whenever any of its stopped child processes are continued. <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"> &nbsp;If <i>sig</i> is SIGCHLD and the SA_NOCLDSTOP flag is set in
<i>sa_flags</i>, then the implementation shall not generate a SIGCHLD signal in this way.</p>
</dd>
<dt>SA_ONSTACK</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If set and an alternate signal stack has been declared with <a href="../functions/sigaltstack.html"><i>sigaltstack</i>()</a>, the
signal shall be delivered to the calling process on that stack. Otherwise, the signal shall be delivered on the current stack. <img
src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>SA_RESETHAND</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If set, the disposition of the signal shall be reset to SIG_DFL and the SA_SIGINFO flag shall be cleared on entry to the signal
handler. <basefont size="2">
<dl>
<dt><b>Note:</b></dt>
<dd>SIGILL and SIGTRAP cannot be automatically reset when delivered; the system silently enforces this restriction.</dd>
</dl>
<basefont size="3"> Otherwise, the disposition of the signal shall not be modified on entry to the signal handler.
<p>In addition, if this flag is set, <i>sigaction</i>() behaves as if the SA_NODEFER flag were also set. <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
</dd>
<dt>SA_RESTART</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
This flag affects the behavior of interruptible functions; that is, those specified to fail with <i>errno</i> set to [EINTR]. If
set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with
[EINTR] unless otherwise specified. If the flag is not set, interruptible functions interrupted by this signal shall fail with
<i>errno</i> set to [EINTR]. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>SA_SIGINFO</dt>
<dd>If cleared and the signal is caught, the signal-catching function shall be entered as:
<pre>
<tt>void func(int</tt> <i>signo</i><tt>);
</tt>
</pre>
<p>where <i>signo</i> is the only argument to the signal-catching function. In this case, the application shall use the
<i>sa_handler</i> member to describe the signal-catching function and the application shall not modify the <i>sa_sigaction</i>
member.</p>
<p><sup>[<a href="javascript:open_code('XSI')">XSI|RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border=
"0"> If SA_SIGINFO is set and the signal is caught, the signal-catching function shall be entered as:</p>
<pre>
<tt>void func(int</tt> <i>signo</i><tt>, siginfo_t *</tt><i>info</i><tt>, void *</tt><i>context</i><tt>);
</tt>
</pre>
<p>where two additional arguments are passed to the signal-catching function. The second argument shall point to an object of type
<b>siginfo_t</b> explaining the reason why the signal was generated; the third argument can be cast to a pointer to an object of
type <b>ucontext_t</b> to refer to the receiving process' context that was interrupted when the signal was delivered. In this case,
the application shall use the <i>sa_sigaction</i> member to describe the signal-catching function and the application shall not
modify the <i>sa_handler</i> member.</p>
<p>The <i>si_signo</i> member contains the system-generated signal number. <img src="../images/opt-end.gif" alt="[Option End]"
border="0"></p>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The <i>si_errno</i> member may contain implementation-defined additional error information; if non-zero, it contains an error
number identifying the condition that caused the signal to be generated. <img src="../images/opt-end.gif" alt="[Option End]"
border="0"></p>
<p><sup>[<a href="javascript:open_code('XSI')">XSI|RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border=
"0"> The <i>si_code</i> member contains a code identifying the cause of the signal. <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></p>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If the value of <i>si_code</i> is less than or equal to 0, then the signal was generated by a process and <i>si_pid</i> and
<i>si_uid</i>, respectively, indicate the process ID and the real user ID of the sender. <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"> The <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> header description contains
information about the signal-specific contents of the elements of the <b>siginfo_t</b> type.</p>
</dd>
<dt>SA_NOCLDWAIT</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If set, and <i>sig</i> equals SIGCHLD, child processes of the calling processes shall not be transformed into zombie processes when
they terminate. If the calling process subsequently waits for its children, and the process has no unwaited-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]. Otherwise, terminating child
processes shall be transformed into zombie processes, unless SIGCHLD is set to SIG_IGN. <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></dd>
<dt>SA_NODEFER</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
If set and <i>sig</i> is caught, <i>sig</i> shall not be added to the process' signal mask on entry to the signal handler unless it
is included in <i>sa_mask</i>. Otherwise, <i>sig</i> shall always be added to the process' signal mask on entry to the signal
handler. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
</dl>
<p>When a signal is caught by a signal-catching function installed by <i>sigaction</i>(), a new signal mask is calculated and
installed for the duration of the signal-catching function (or until a call to either <a href=
"../functions/sigprocmask.html"><i>sigprocmask</i>()</a> or <a href="../functions/sigsuspend.html"><i>sigsuspend</i>()</a> is
made). This mask is formed by taking the union of the current signal mask and the value of the <i>sa_mask</i> for the signal being
delivered <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
border="0"> &nbsp;unless SA_NODEFER or SA_RESETHAND is set, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> and
then including the signal being delivered. If and when the user's signal handler returns normally, the original signal mask is
restored.</p>
<p>Once an action is installed for a specific signal, it shall remain installed until another action is explicitly requested (by
another call to <i>sigaction</i>()), <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif"
alt="[Option Start]" border="0"> &nbsp;until the SA_RESETHAND flag causes resetting of the handler, <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"> &nbsp;or until one of the <i><a href="../functions/exec.html">exec</a></i>
functions is called.</p>
<p>If the previous action for <i>sig</i> had been established by <a href="../functions/signal.html"><i>signal</i>()</a>, the values
of the fields returned in the structure pointed to by <i>oact</i> are unspecified, and in particular <i>oact</i>-&gt;
<i>sa_handler</i> is not necessarily the same value passed to <a href="../functions/signal.html"><i>signal</i>()</a>. However, if a
pointer to the same structure or a copy thereof is passed to a subsequent call to <i>sigaction</i>() via the <i>act</i> argument,
handling of the signal shall be as if the original call to <a href="../functions/signal.html"><i>signal</i>()</a> were
repeated.</p>
<p>If <i>sigaction</i>() fails, no new signal handler is installed.</p>
<p>It is unspecified whether an attempt to set the action for a signal that cannot be caught or ignored to SIG_DFL is ignored or
causes an error to be returned with <i>errno</i> set to [EINVAL].</p>
<p>If SA_SIGINFO is not set in <i>sa_flags</i>, then the disposition of subsequent occurrences of <i>sig</i> when it is already
pending is implementation-defined; the signal-catching function shall be invoked with a single argument. <sup>[<a href=
"javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;If the
implementation supports the Realtime Signals Extension option, and if SA_SIGINFO is set in <i>sa_flags</i>, then subsequent
occurrences of <i>sig</i> generated by <a href="../functions/sigqueue.html"><i>sigqueue</i>()</a> or as a result of any
signal-generating function that supports the specification of an application-defined value (when <i>sig</i> is already pending)
shall be queued in FIFO order until delivered or accepted; the signal-catching function shall be invoked with three arguments. The
application specified value is passed to the signal-catching function as the <i>si_value</i> member of the <b>siginfo_t</b>
structure. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>The result of the use of <i>sigaction</i>() and a <a href="../functions/sigwait.html"><i>sigwait</i>()</a> function concurrently
within a process on the same signal is unspecified.</p>
</blockquote>
<h4><a name="tag_03_680_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, <i>sigaction</i>() shall return 0; otherwise, -1 shall be returned, <i>errno</i> shall be set to
indicate the error, and no new signal-catching function shall be installed.</p>
</blockquote>
<h4><a name="tag_03_680_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>sigaction</i>() function shall fail if:</p>
<dl compact>
<dt>[EINVAL]</dt>
<dd>The <i>sig</i> argument is not a valid signal number or an attempt is made to catch a signal that cannot be caught or ignore a
signal that cannot be ignored.</dd>
<dt>[ENOTSUP]</dt>
<dd>The SA_SIGINFO bit flag is set in the <i>sa_flags</i> field of the <b>sigaction</b> structure, and the implementation does not
support either the Realtime Signals Extension option, or the XSI Extension option.</dd>
</dl>
<p>The <i>sigaction</i>() function may fail if:</p>
<dl compact>
<dt>[EINVAL]</dt>
<dd>An attempt was made to set the action to SIG_DFL for a signal that cannot be caught or ignored (or both).</dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_680_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_680_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>The <i>sigaction</i>() function supersedes the <a href="../functions/signal.html"><i>signal</i>()</a> function, and should be
used in preference. In particular, <i>sigaction</i>() and <a href="../functions/signal.html"><i>signal</i>()</a> should not be used
in the same process to control the same signal. The behavior of reentrant functions, as defined in the DESCRIPTION, is as specified
by this volume of IEEE&nbsp;Std&nbsp;1003.1-2001, regardless of invocation from a signal-catching function. This is the only
intended meaning of the statement that reentrant functions may be used in signal-catching functions without restrictions.
Applications must still consider all effects of such functions on such things as data structures, files, and process state. In
particular, application writers need to consider the restrictions on interactions when interrupting <a href=
"../functions/sleep.html"><i>sleep</i>()</a> and interactions among multiple handles for a file description. The fact that any
specific function is listed as reentrant does not necessarily mean that invocation of that function from a signal-catching function
is recommended.</p>
<p>In order to prevent errors arising from interrupting non-reentrant function calls, applications should protect calls to these
functions either by blocking the appropriate signals or through the use of some programmatic semaphore (see <a href=
"semget.html"><i>semget</i>()</a> , <a href="sem_init.html"><i>sem_init</i>()</a> , <a href="sem_open.html"><i>sem_open</i>()</a> ,
and so on). Note in particular that even the &quot;safe&quot; functions may modify <i>errno</i>; the signal-catching function, if not
executing as an independent thread, may want to save and restore its value. Naturally, the same principles apply to the reentrancy
of application routines and asynchronous data access. Note that <a href="../functions/longjmp.html"><i>longjmp</i>()</a> and <a
href="../functions/siglongjmp.html"><i>siglongjmp</i>()</a> are not in the list of reentrant functions. This is because the code
executing after <a href="../functions/longjmp.html"><i>longjmp</i>()</a> and <a href=
"../functions/siglongjmp.html"><i>siglongjmp</i>()</a> can call any unsafe functions with the same danger as calling those unsafe
functions directly from the signal handler. Applications that use <a href="../functions/longjmp.html"><i>longjmp</i>()</a> and <a
href="../functions/siglongjmp.html"><i>siglongjmp</i>()</a> from within signal handlers require rigorous protection in order to be
portable. Many of the other functions that are excluded from the list are traditionally implemented using either <a href=
"../functions/malloc.html"><i>malloc</i>()</a> or <a href="../functions/free.html"><i>free</i>()</a> functions or the standard I/O
library, both of which traditionally use data structures in a non-reentrant manner. Since any combination of different functions
using a common data structure can cause reentrancy problems, this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 does not define the
behavior when any unsafe function is called in a signal handler that interrupts an unsafe function.</p>
<p>If the signal occurs other than as the result of calling <a href="../functions/abort.html"><i>abort</i>()</a>, <a href=
"../functions/kill.html"><i>kill</i>()</a>, or <a href="../functions/raise.html"><i>raise</i>()</a>, the behavior is undefined if
the signal handler calls any function in the standard library other than one of the functions listed in the table above or refers
to any object with static storage duration other than by assigning a value to a static storage duration variable of type
<b>volatile sig_atomic_t</b>. Furthermore, if such a call fails, the value of <i>errno</i> is unspecified.</p>
<p>Usually, the signal is executed on the stack that was in effect before the signal was delivered. An alternate stack may be
specified to receive a subset of the signals being caught.</p>
<p>When the signal handler returns, the receiving process resumes execution at the point it was interrupted unless the signal
handler makes other arrangements. If <a href="../functions/longjmp.html"><i>longjmp</i>()</a> or <a href=
"../functions/_longjmp.html"><i>_longjmp</i>()</a> is used to leave the signal handler, then the signal mask must be explicitly
restored by the process.</p>
<p>This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defines the third argument of a signal handling function when SA_SIGINFO is set as
a <b>void *</b> instead of a <b>ucontext_t *</b>, but without requiring type checking. New applications should explicitly cast the
third argument of the signal handling function to <b>ucontext_t *</b>.</p>
<p>The BSD optional four argument signal handling function is not supported by this volume of IEEE&nbsp;Std&nbsp;1003.1-2001. The
BSD declaration would be:</p>
<pre>
<tt>void handler(int</tt> <i>sig</i><tt>, int</tt> <i>code</i><tt>, struct sigcontext *</tt><i>scp</i><tt>,
char *</tt><i>addr</i><tt>);
</tt>
</pre>
<p>where <i>sig</i> is the signal number, <i>code</i> is additional information on certain signals, <i>scp</i> is a pointer to the
<b>sigcontext</b> structure, and <i>addr</i> is additional address information. Much the same information is available in the
objects pointed to by the second argument of the signal handler specified when SA_SIGINFO is set.</p>
</blockquote>
<h4><a name="tag_03_680_08"></a>RATIONALE</h4>
<blockquote>
<p>Although this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 requires that signals that cannot be ignored shall not be added to the
signal mask when a signal-catching function is entered, there is no explicit requirement that subsequent calls to
<i>sigaction</i>() reflect this in the information returned in the <i>oact</i> argument. In other words, if SIGKILL is included in
the <i>sa_mask</i> field of <i>act</i>, it is unspecified whether or not a subsequent call to <i>sigaction</i>() returns with
SIGKILL included in the <i>sa_mask</i> field of <i>oact</i>.</p>
<p>The SA_NOCLDSTOP flag, when supplied in the <i>act</i>-&gt; <i>sa_flags</i> parameter, allows overloading SIGCHLD with the
System V semantics that each SIGCLD signal indicates a single terminated child. Most conforming applications that catch SIGCHLD are
expected to install signal-catching functions that repeatedly call the <a href="../functions/waitpid.html"><i>waitpid</i>()</a>
function with the WNOHANG flag set, acting on each child for which status is returned, until <a href=
"../functions/waitpid.html"><i>waitpid</i>()</a> returns zero. If stopped children are not of interest, the use of the SA_NOCLDSTOP
flag can prevent the overhead from invoking the signal-catching routine when they stop.</p>
<p>Some historical implementations also define other mechanisms for stopping processes, such as the <i>ptrace</i>() function. These
implementations usually do not generate a SIGCHLD signal when processes stop due to this mechanism; however, that is beyond the
scope of this volume of IEEE&nbsp;Std&nbsp;1003.1-2001.</p>
<p>This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 requires that calls to <i>sigaction</i>() that supply a NULL <i>act</i> argument
succeed, even in the case of signals that cannot be caught or ignored (that is, SIGKILL or SIGSTOP). The System V <a href=
"../functions/signal.html"><i>signal</i>()</a> and BSD <i>sigvec</i>() functions return [EINVAL] in these cases and, in this
respect, their behavior varies from <i>sigaction</i>().</p>
<p>This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 requires that <i>sigaction</i>() properly save and restore a signal action set up
by the ISO&nbsp;C standard <a href="../functions/signal.html"><i>signal</i>()</a> function. However, there is no guarantee that the
reverse is true, nor could there be given the greater amount of information conveyed by the <b>sigaction</b> structure. Because of
this, applications should avoid using both functions for the same signal in the same process. Since this cannot always be avoided
in case of general-purpose library routines, they should always be implemented with <i>sigaction</i>().</p>
<p>It was intended that the <a href="../functions/signal.html"><i>signal</i>()</a> function should be implementable as a library
routine using <i>sigaction</i>().</p>
<p>The POSIX Realtime Extension extends the <i>sigaction</i>() function as specified by the POSIX.1-1990 standard to allow the
application to request on a per-signal basis via an additional signal action flag that the extra parameters, including the
application-defined signal value, if any, be passed to the signal-catching function.</p>
</blockquote>
<h4><a name="tag_03_680_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_680_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="xsh_chap02_04.html#tag_02_04"><i>Signal Concepts</i></a> , <a href="bsd_signal.html"><i>bsd_signal</i>()</a> , <a href=
"kill.html"><i>kill</i>()</a> , <a href="_longjmp.html"><i>_longjmp</i>()</a> , <a href="longjmp.html"><i>longjmp</i>()</a> , <a
href="raise.html"><i>raise</i>()</a> , <a href="semget.html"><i>semget</i>()</a> , <a href="sem_init.html"><i>sem_init</i>()</a> ,
<a href="sem_open.html"><i>sem_open</i>()</a> , <a href="sigaddset.html"><i>sigaddset</i>()</a> , <a href=
"sigaltstack.html"><i>sigaltstack</i>()</a> , <a href="sigdelset.html"><i>sigdelset</i>()</a> , <a href=
"sigemptyset.html"><i>sigemptyset</i>()</a> , <a href="sigfillset.html"><i>sigfillset</i>()</a> , <a href=
"sigismember.html"><i>sigismember</i>()</a> , <a href="signal.html"><i>signal</i>()</a> , <a href=
"sigprocmask.html"><i>sigprocmask</i>()</a> , <a href="sigsuspend.html"><i>sigsuspend</i>()</a> , <a href=
"wait.html"><i>wait</i>()</a> , <a href="waitid.html"><i>waitid</i>()</a> , <a href="waitpid.html"><i>waitpid</i>()</a> , the Base
Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a>, <a href=
"../basedefs/ucontext.h.html"><i>&lt;ucontext.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_680_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.</p>
</blockquote>
<h4><a name="tag_03_680_12"></a>Issue 5</h4>
<blockquote>
<p>The DESCRIPTION is updated for alignment with the POSIX Realtime Extension and POSIX Threads Extension.</p>
<p>In the DESCRIPTION, the second argument to <i>func</i> when SA_SIGINFO is set is no longer permitted to be NULL, and the
description of permitted <b>siginfo_t</b> contents is expanded by reference to <a href=
"../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a>.</p>
<p>Since the X/OPEN UNIX Extension functionality is now folded into the BASE, the [ENOTSUP] error is deleted.</p>
</blockquote>
<h4><a name="tag_03_680_13"></a>Issue 6</h4>
<blockquote>
<p>The Open Group Corrigendum U028/7 is applied. In the paragraph entitled &quot;Signal Effects on Other Functions&quot;, a reference to <a
href="../functions/sigpending.html"><i>sigpending</i>()</a> is added.</p>
<p>In the DESCRIPTION, the text &quot;Signal Generation and Delivery&quot;, &quot;Signal Actions&quot;, and &quot;Signal Effects on Other Functions''
are moved to a separate section of this volume of IEEE&nbsp;Std&nbsp;1003.1-2001.</p>
<p>Text describing functionality from the Realtime Signals option is marked.</p>
<p>The following changes are made for alignment with the ISO&nbsp;POSIX-1:1996 standard:</p>
<ul>
<li>
<p>The [ENOTSUP] error condition is added.</p>
</li>
</ul>
<p>The DESCRIPTION is updated to avoid use of the term &quot;must&quot; for application requirements.</p>
<p>The <b>restrict</b> keyword is added to the <i>sigaction</i>() prototype for alignment with the ISO/IEC&nbsp;9899:1999
standard.</p>
<p>References to the <i>wait3</i>() function are removed.</p>
<p>The SYNOPSIS is marked CX since the presence of this function in the <a href=
"../basedefs/signal.h.html"><i>&lt;signal.h&gt;</i></a> header is an extension over the ISO&nbsp;C standard.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; 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>