.TH sigaction() "" "" "System Call (libc)"
.PC "Perform detailed signal management"
.B "#include <signal.h>"
\fBint sigaction (\fIsignal\^\fB, \fIaction\^\fB, \fIold_action\^\fB)\fR
\fBint \fIsignal\^\fB; \fBconst struct sigaction *\fIaction\^\fB; \fBstruct sigaction *\fIold_action\^\fB;\fR
.PP
.B sigaction()
lets the calling process specify the action it will take when it receives
.IR signal .
.PP
.I signal
can be any of the signals named in the Lexicon entry for
.B signal()
except
.B SIGKILL
and
.BR SIGSTOP .
.PP
.I action
points to a structure that specifies the action to take when
.I signal
is received.
If
.I action
is set to NULL, the current disposition of the signal is unaffected.
.PP
.I old_action
points to a structure that describes the action previously associated with
.IR signal ,
and that is to be restored upon return from
.BR sigaction() .
.PP
The structure
.B sigaction
has the following members:
.DM
	void	(*sa_handler)();
	sigset_t	sa_mask;
	int	sa_flags;
.DE
.PP
.B sa_handler
gives the disposition of the signal.
You can set it to any of the actions described in the article for
.BR signal() .
.PP
.B sa_mask
identifies the signals to be blocked while the signal handler is active.
Upon entry to the signal handler,
that set of signals is added to the set of signals already being blocked when
.I signal
was received.
.I signal
itself is also blocked.
Note that you cannot block
.B SIGSTOP
and
.BR SIGKILL .
.PP
.B sa_flags
specifies a set of flags used to modify the behavior of
.IR signal .
As of this writing,
.B sigaction()
recognizes only the flag \fBSA_NOCLDSTOP\fR:
If this is set and
.I signal
equals
.BR SIGCHLD ,
.I signal
is not sent to the calling process when its child processes stop or continue.
.PP
.B sigaction()
returns zero if all is well.
It fails and returns \-1 if either of the following is true:
.IP \(bu 0.3i
.I signal
does not identify a valid signal.
.B sigaction()
sets
.B errno
to
.BR EINVAL .
.IP \(bu
.I action
or
.I old_action
points outside the process's allocated address space.
.B sigaction()
sets
.B errno
to
.BR EFAULT .
.SH "See Also"
.Xr "libc," libc
.Xr "sigaddset()," sigaddset
.Xr "sigdelset()," sigdelset
.Xr "sigemptyset()," sigemptys
.Xr "sigfillset()," sigfillse
.Xr "sigismember()," sigismemb
.Xr "signal()," signal
.Xr "signal.h," signal.h
.Xr "sigpending()," sigpendin
.Xr "sigprocmask()," sigprocma
.Xr "sigset()," sigset
.Xr "siglongjmp()," siglongjm
.Xr "sigsetjmp()," sigsetjmp
.Xr "sigsuspend()" sigsuspen
.br
\*(PX Standard, \(sc3.3.4
