Go to the previous, next section.
The sigaction function has the same basic effect as
signal: to specify how a signal should be handled by the process.
However, sigaction offers more control, at the expense of more
complexity. In particular, sigaction allows you to specify
additional flags to control when the signal is generated and how the
handler is invoked.
The sigaction function is declared in `signal.h'.
Structures of type struct sigaction are used in the
sigaction function to specify all the information about how to
handle a particular signal. This structure contains at least the
following members:
sighandler_t sa_handler
signal function. The value can be SIG_DFL,
SIG_IGN, or a function pointer. See section Basic Signal Handling.
sigset_t sa_mask
sa_mask. If you want that signal not to be blocked within its
handler, you must write code in the handler to unblock it.
int sa_flags
sigaction.
Function: int sigaction (int signum, const struct sigaction *action, struct sigaction *old_action)
The action argument is used to set up a new action for the signal
signum, while the old_action argument is used to return
information about the action previously associated with this symbol.
(In other words, old_action has the same purpose as the
signal function's return value--you can check to see what the
old action in effect for the signal was, and restore it later if you
want.)
Either action or old_action can be a null pointer. If old_action is a null pointer, this simply suppresses the return of information about the old action. If action is a null pointer, the action associated with the signal signum is unchanged; this allows you to inquire about how a signal is being handled without changing that handling.
The return value from sigaction is zero if it succeeds, and
-1 on failure. The following errno error conditions are
defined for this function:
EINVAL
SIGKILL or SIGSTOP.
Go to the previous, next section.