#include <signal.h> int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
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.
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.
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 identifies a set of signals that shall be added to the signal mask of the process before the signal-catching function is invoked. Ths SIGKILL and SIGSTOP signals shall not be added to the signal mask using this mechanism.
The SA_NOCLDSTOP bit of the sa_flags field may be used to modify the behavior of the specified signal. If sig is SIGCHLD and the SA_NOCLDSTOP flag is not set in sa_flags, a SIGCHLD signal shall be generated for the calling process whenever any of its child processes stop.
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(2P) or sigsuspend(2P) 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 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(2) functions is called.
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 21/April/97