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
- The signum argument is not valid, or you are trying to
trap or ignore
SIGKILL
or SIGSTOP
.