sigaction [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation
MPE/iX Developer's Kit Reference Manual Volume I
sigaction
Examines and/or changes a signal action.
Syntax
#include <signal.h>
int sigaction (int sig, const struct sigaction *act,
struct sigaction *oact);
Parameters
sig The signal number of the signal to examine or change. Valid
signals are described in Table 3-5 .
act If not NULL, a pointer to a structure of type sigaction that
describes a new signal action to be associated with sig. If
NULL, the current signal action is unchanged.
oact If not NULL, a pointer to a structure of type sigaction that
returns the description of the current action for the signal
sig (prior to any changes). If NULL, the current action is
not returned.
Return Values
0 Success.
-1 An error occurred. The signal action is not changed, and
errno is set to indicate the error condition.
Description
The sigaction() function enables the calling process to examine or change
(or both) the action associated with the specified signal.
In order to examine the current action associated with a signal without
changing the current action, set act to NULL. In order to change an
action associated with a signal, define the new signal action in a
structure of type sigaction and pass it in act. Refer to the following
discussion of the sigaction structure.
The sigaction structure, defined in <signal.h>, includes the following
fields:
Member Type Member Name Description
void (*)() sa_handler Either SIG_DFL for the default action, SIG_IGN to
ignore the signal, or a pointer to a signal handling
function (a signal handler).
sigset_t sa_mask; Additional signals to be blocked during execution of
the signal handler specified in sa_handler.
int sa_flags; If sig specifies SIGCHLD and sa_flags specifies
SA_NOCLDSTOP, a SIGCHLD signal is not generated for
the calling process whenever any of its child
processes stop. If sig specifies SIGCHLD and
sa_flags does not specify SA_NOCLDSTOP, SIGCHLD is
generated for the calling process whenever any of its
child processes stop.
When installing a new signal handler, you must specify in sa_mask any
additional signals to be blocked during the execution of the signal
handler. When a signal is caught by a signal handler installed by
sigaction(), a new signal mask is calculated and installed for the
duration of the signal handler (or until a call to either sigprocmask()
or sigsuspend()).
This mask is formed by taking a union of the current signal mask and
sa_mask for the signal being delivered, then including the signal being
delivered. If and when the signal handler returns normally, the original
signal mask is restored.
The signals SIGKILL and SIGSTOP, if specified in the sa_mask field, are
removed by the system without error.
The structure passed in sa_mask must be initialized by either the
sigemptyset() or the sigfillset() functions before adding or removing
signals from it using the sigaddset() or sigdelset() functions.
A signal action installed by sigaction() remains in effect until changed
by another call to sigaction() or until the next call to one of the
exec() functions.
The sigaction() function is incompatible with the ANSI C signal()
function. The sigaction() function can return and reinstall a signal
action that was originally installed by signal(); however, the structure
that sigaction() returns in oact may not reliably be examined by the
caller. If this same signal action is later reinstalled, without
modification, by another call to sigaction(), the result is as if the
original call to signal() were repeated.
Implementation Considerations
Refer to the EFAULT error description below.
Errors
If an error occurs, errno is set to one of the following values:
EFAULT CAUSE The system detected a bad address in attempting to
use the act or oact parameters.
ACTION Make sure that the pointer is correctly initialized.
EINVAL CAUSE One of the following:
* The sig parameter is not a valid signal
number.
* An attempt was made to handle a signal that
cannot be handled or to ignore a signal that
cannot be ignored.
* An attempt was made to change the action from
SIGDFL for a signal that cannot be handled or
ignored.
ACTION Refer to Table 3-5 for descriptions of valid and
supported signal numbers.
See Also
kill(), sigprocmask(), sigsuspend(), <signal.h>, POSIX.1 (Section 3.3.4)
MPE/iX 5.0 Documentation