SIGACTION(S) UNIX System V SIGACTION(S)
Name
sigaction - examine and change signal action
Syntax
#include <signal.h>
int sigaction (sig, act, oact)
int sig;
struct sigaction *act, *oact;
Description
The sigaction() function allows the calling process to
examine or specify (or both) the action to be associated
with a specific signal. The argument sig specifies the
signal; acceptable values are defined in <signal.h> .
The structure sigaction, used to describe an action to be
taken, is defined in the header <signal.h> to include at
least the following members:
Member Member
Type Name Description
_____________________________________________________________________
void (*)() sa_handler SIG_DFL, SIG_IGN, or pointer to a function.
sigset_t sa_mask Additional set of signals to be blocked
during execution of signal-catching
function.
int sa_flags Special flags to affect behavior of signal.
If the argument act is not NULL , it points to a structure
specifying the action to be associated with the specified
signal. If the argument oact is not NULL , the action
previously associated with the signal is stored in the
location pointed to by the argument oact. If the argument
act is NULL , signal handling is unchanged by this function
call; thus, the call can be used to enquire about the
current handling of a given signal. The sa_handler field of
the sigaction structure identifies the action to be
associated with the specified signal. If the sa_handler
field specifies a signal-catching function, the sa_mask
field identities a set of signals that are added to the
process's signal mask before the signal-catching function is
invoked. The SIGKILL and SIGSTOP signals are not be added
to the signal mask using this mechanism; this restriction is
enforced by the system without causing an error to be
indicated.
The sa_flags field can be used to modify the behavior of the
specified signal.
The following flag bit, defined in the header <signal.h>,
can be set in sa_flags:
Symbolic
Constant Description
_________________________________________________________
SA_NOCLDSTOP Do not generate SIGCHLD when children stop
If sig is SIGCHLD and the SA_NOCLDSTOP flag is not set in
sa_flags, and the implementation supports the SIGCHLD
signal, a SIGCHLD signal is generated for the calling
process whenever any of its child processes stop. If sig is
SIGCHLD and the SA_NOCLDSTOP flag is set in sa_flags, the
implementation does not generate a SIGCHLD signal in this
way.
When a signal is caught by a signal-catching function
installed by the sigaction() function, a new signal mask is
calculated and installed for the duration of the signal-
catching function (or until a call to either the
sigprocmask() or sigsuspend() function is made). This mask
is formed by taking the union of the current signal mask and
the value of the sa_mask for the signal being delivered, and
then including the signal being delivered. If and when the
user's signal handler returns normally, the original signal
mask is restored.
Once an action is installed for a specific signal, it
remains installed until another action is explicitly
requested (by another call to the sigaction() function), or
until one of the exec functions is called.
If the previous action for sig had been established by the
signal() function, the values of the fields returned in the
structure pointed to by oact are unspecified, and in
particular oact->su_handler is not necessarily the same
value passed to the signal() function. However, if a
pointer to the same structure or a copy thereof is passed to
a subsequent call to the sigaction() function via the act
argument, handling of the signal is as if the original call
to the signal() function were repeated.
If the sigaction() function fails, no new signal handler is
installed.
Return Value
Upon successful completion a value of zero is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
See Also
kill(S), signal(S), sigset(S)
Diagnostics
If any of the following conditions occur, the sigaction()
function shall return -1 and set errno to the corresponding
value:
[EINVAL] The value of the sig argument is an invalid or
unsupported signal number, or an attempt was made
to catch a signal that cannot be caught or to
ignore a signal that cannot be ignored. See
signal(S).
Standards Conformance
sigaction is conformant with:
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
(printed 6/20/89)