HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)

s
sigaction(2) sigaction(2)
NAME
sigaction - examine and change signal action
SYNOPSIS
#include <signal.h>
int sigaction (
int sig,
const struct sigaction *act,
struct sigaction *oact
);
DESCRIPTION
The sigaction() function allows the calling process to examine and/or specify the action to be associ-
ated 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 Type Member Name Description
SIG_DFL, SIG_IGN or pointer to a
function.void(*)(int) sa_handler
Additional set of signals to be blocked
during execution of signal-catching
function.sigset_t sa_mask
Special ags to affect behavior of sig-
nal.int sa_flags
signal-catching function.void(*)(int, siginfo_t*,void *) sa_sigaction
If the argument act is not a null pointer, it points to a structure specifying the action to be associated with
the specified signal. If the argument oact is not a null pointer, the action previously associated with the
signal is stored in the location pointed to by the argument oact.
If the argument act is a null pointer, signal handling is unchanged; 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 func-
tion, the sa_mask eld identifies a set of signals that will be added to the thread’s signal mask before the
signal-catching function is invoked. The
SIGKILL and SIGSTOP signals will not be added to the signal
mask using this mechanism; this restriction will be 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 flags, defined in
the header
<signal.h> , can be set in sa_flags:
SA_NOCLDSTOP Do not generate SIGCHLD when children stop.
SA_ONSTACK If set and an alternate signal stack has been declared with
sigaltstack() or sigstack(), the signal will be delivered to the cal-
ling process on that stack. Otherwise, the signal will be delivered on the
current stack.
SA_RESETHAND If set, the disposition of the signal will be reset to SIG_DFL and the
SA_SIGINFO flag will be cleared on entry to the signal handler (Note:
SIGILL, SIGTRAP, and SIGPWR cannot be automatically reset when
delivered; the system silently enforces this restriction). Otherwise, the dispo-
sition of the signal will not be modified on entry to the signal handler. In
addition, if this flag is set, sigaction() behaves as if the SA_NODEFER
flag were also set.
SA_RESTART This flag affects the behavior of interruptible functions; that is, those specified
to fail with errno set to [EINTR]. If set, and a function specified as
422 Hewlett-Packard Company 1 HP-UX 11i Version 3: February 2007