2004-11-03 13:51:07 +00:00
|
|
|
'\" t
|
|
|
|
.\" Copyright (c) 1994,1995 Mike Battersby <mib@deakin.edu.au>
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" based on work by faith@cs.unc.edu
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Modified, aeb, 960424
|
|
|
|
.\" Modified Fri Jan 31 17:31:20 1997 by Eric S. Raymond <esr@thyrsus.com>
|
|
|
|
.\" Modified Thu Nov 26 02:12:45 1998 by aeb - add SIGCHLD stuff.
|
2004-11-11 14:09:54 +00:00
|
|
|
.\" Modified Sat May 8 17:40:19 1999 by Matthew Wilcox
|
|
|
|
.\" add POSIX.1b signals
|
|
|
|
.\" Modified Sat Dec 29 01:44:52 2001 by Evan Jones <ejones@uwaterloo.ca>
|
|
|
|
.\" SA_ONSTACK
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified 2004-11-11 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-11 14:09:54 +00:00
|
|
|
.\" Added mention of SIGCONT under SA_NOCLDSTOP
|
|
|
|
.\" Added SA_NOCLDWAIT
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified 2004-11-17 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-18 13:37:14 +00:00
|
|
|
.\" Updated discussion for POSIX.1-2001 and SIGCHLD and sa_flags.
|
|
|
|
.\" Formatting fixes
|
2004-12-09 10:26:18 +00:00
|
|
|
.\" 2004-12-09, mtk, added SI_TKILL + other minor changes
|
2005-09-15 11:47:39 +00:00
|
|
|
.\" 2005-09-15, mtk, split sigpending(), sigprocmask(), sigsuspend()
|
|
|
|
.\" out of this page into separate pages.
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
2007-06-29 17:34:20 +00:00
|
|
|
.TH SIGACTION 2 2005-07-08 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
2005-09-15 11:47:39 +00:00
|
|
|
sigaction \- examine and change a signal action
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
2007-04-03 14:04:54 +00:00
|
|
|
.nf
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <signal.h>
|
2007-04-12 22:42:49 +00:00
|
|
|
.sp
|
2004-11-03 13:51:07 +00:00
|
|
|
.BI "int sigaction(int " signum ", const struct sigaction *" act ,
|
2007-04-03 14:04:54 +00:00
|
|
|
.BI " struct sigaction *" oldact );
|
|
|
|
.fi
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The
|
2004-11-18 13:37:14 +00:00
|
|
|
.BR sigaction ()
|
2004-11-03 13:51:07 +00:00
|
|
|
system call is used to change the action taken by a process on
|
|
|
|
receipt of a specific signal.
|
|
|
|
.PP
|
|
|
|
.I signum
|
|
|
|
specifies the signal and can be any valid signal except
|
|
|
|
.B SIGKILL
|
|
|
|
and
|
|
|
|
.BR SIGSTOP .
|
|
|
|
.PP
|
|
|
|
If
|
|
|
|
.I act
|
|
|
|
is non\-null, the new action for signal
|
|
|
|
.I signum
|
|
|
|
is installed from
|
|
|
|
.IR act .
|
|
|
|
If
|
|
|
|
.I oldact
|
|
|
|
is non\-null, the previous action is saved in
|
|
|
|
.IR oldact .
|
|
|
|
.PP
|
|
|
|
The
|
2004-11-18 13:37:14 +00:00
|
|
|
.I sigaction
|
2004-11-03 13:51:07 +00:00
|
|
|
structure is defined as something like
|
|
|
|
.sp
|
2007-12-07 19:53:58 +00:00
|
|
|
.RS 4
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
struct sigaction {
|
2007-04-03 14:04:54 +00:00
|
|
|
void (*sa_handler)(int);
|
|
|
|
void (*sa_sigaction)(int, siginfo_t *, void *);
|
|
|
|
sigset_t sa_mask;
|
|
|
|
int sa_flags;
|
|
|
|
void (*sa_restorer)(void);
|
2004-11-03 13:51:07 +00:00
|
|
|
}
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.PP
|
2005-07-06 06:54:27 +00:00
|
|
|
On some architectures a union is involved: do not assign to both
|
2004-11-03 13:51:07 +00:00
|
|
|
.I sa_handler
|
|
|
|
and
|
|
|
|
.IR sa_sigaction .
|
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.I sa_restorer
|
|
|
|
element is obsolete and should not be used.
|
|
|
|
POSIX does not specify a
|
|
|
|
.I sa_restorer
|
|
|
|
element.
|
|
|
|
.PP
|
|
|
|
.I sa_handler
|
|
|
|
specifies the action to be associated with
|
|
|
|
.I signum
|
|
|
|
and may be
|
|
|
|
.B SIG_DFL
|
2007-04-12 22:42:49 +00:00
|
|
|
for the default action,
|
2004-11-03 13:51:07 +00:00
|
|
|
.B SIG_IGN
|
|
|
|
to ignore this signal, or a pointer to a signal handling function.
|
|
|
|
This function receives the signal number as its only argument.
|
|
|
|
.PP
|
2005-09-15 11:47:39 +00:00
|
|
|
If
|
|
|
|
.B SA_SIGINFO
|
|
|
|
is specified in
|
2007-04-12 22:42:49 +00:00
|
|
|
.IR sa_flags ,
|
2005-09-15 11:47:39 +00:00
|
|
|
then
|
2004-11-03 13:51:07 +00:00
|
|
|
.I sa_sigaction
|
2005-09-15 11:47:39 +00:00
|
|
|
(instead of
|
|
|
|
.IR sa_handler )
|
|
|
|
specifies the signal-handling function for
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR signum .
|
|
|
|
This function receives the signal number as its first argument, a
|
|
|
|
pointer to a
|
|
|
|
.I siginfo_t
|
|
|
|
as its second argument and a pointer to a
|
|
|
|
.I ucontext_t
|
|
|
|
(cast to void *) as its third argument.
|
|
|
|
.PP
|
|
|
|
.I sa_mask
|
|
|
|
gives a mask of signals which should be blocked during execution of
|
2007-04-12 22:42:49 +00:00
|
|
|
the signal handler.
|
|
|
|
In addition, the signal which triggered the handler
|
2004-11-03 13:51:07 +00:00
|
|
|
will be blocked, unless the
|
|
|
|
.B SA_NODEFER
|
2004-11-18 13:37:14 +00:00
|
|
|
flag is used.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
.I sa_flags
|
2007-06-08 09:56:56 +00:00
|
|
|
specifies a set of flags which modify the behavior of the signal handling
|
2007-04-12 22:42:49 +00:00
|
|
|
process.
|
|
|
|
It is formed by the bitwise OR of zero or more of the following:
|
2004-11-03 13:51:07 +00:00
|
|
|
.RS
|
|
|
|
.TP
|
|
|
|
.B SA_NOCLDSTOP
|
|
|
|
If
|
|
|
|
.I signum
|
|
|
|
is
|
2004-11-11 14:09:54 +00:00
|
|
|
.BR SIGCHLD ,
|
|
|
|
do not receive notification when child processes stop (i.e., when they
|
|
|
|
receive one of
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR SIGSTOP ", " SIGTSTP ", " SIGTTIN
|
|
|
|
or
|
2004-11-11 14:09:54 +00:00
|
|
|
.BR SIGTTOU )
|
|
|
|
or resume (i.e., they receive
|
|
|
|
.BR SIGCONT )
|
|
|
|
(see
|
|
|
|
.BR wait (2)).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2004-11-11 14:09:54 +00:00
|
|
|
.B SA_NOCLDWAIT
|
|
|
|
(Linux 2.6 and later)
|
|
|
|
.\" To be precise: Linux 2.5.60 -- MTK
|
|
|
|
If
|
|
|
|
.I signum
|
|
|
|
is
|
|
|
|
.BR SIGCHLD ,
|
|
|
|
do not transform children into zombies when they terminate.
|
|
|
|
See also
|
2004-11-18 13:37:14 +00:00
|
|
|
.BR waitpid (2).
|
2004-11-11 14:09:54 +00:00
|
|
|
.TP
|
|
|
|
.B SA_RESETHAND
|
2004-11-03 13:51:07 +00:00
|
|
|
Restore the signal action to the default state once the signal handler
|
|
|
|
has been called.
|
2004-11-11 14:09:54 +00:00
|
|
|
.B SA_ONESHOT
|
|
|
|
is an obsolete, non-standard synonym for this flag.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2007-09-20 16:26:31 +00:00
|
|
|
.B SA_ONSTACK
|
2007-04-12 22:42:49 +00:00
|
|
|
Call the signal handler on an alternate signal stack provided by
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR sigaltstack (2).
|
|
|
|
If an alternate stack is not available, the default stack will be used.
|
|
|
|
.TP
|
|
|
|
.B SA_RESTART
|
2007-06-08 09:56:56 +00:00
|
|
|
Provide behavior compatible with BSD signal semantics by making certain
|
2004-11-03 13:51:07 +00:00
|
|
|
system calls restartable across signals.
|
|
|
|
.TP
|
2004-11-11 14:09:54 +00:00
|
|
|
.B SA_NODEFER
|
2004-11-03 13:51:07 +00:00
|
|
|
Do not prevent the signal from being received from within its own signal
|
|
|
|
handler.
|
2004-11-11 14:09:54 +00:00
|
|
|
.B SA_NOMASK
|
|
|
|
is an obsolete, non-standard synonym for this flag.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B SA_SIGINFO
|
2007-04-12 22:42:49 +00:00
|
|
|
The signal handler takes 3 arguments, not one.
|
|
|
|
In this case,
|
2004-11-03 13:51:07 +00:00
|
|
|
.I sa_sigaction
|
|
|
|
should be set instead of
|
|
|
|
.IR sa_handler .
|
2004-11-18 13:37:14 +00:00
|
|
|
(The
|
|
|
|
.I sa_sigaction
|
|
|
|
field was added in Linux 2.1.86.)
|
2004-11-03 13:51:07 +00:00
|
|
|
.RE
|
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.I siginfo_t
|
|
|
|
parameter to
|
|
|
|
.I sa_sigaction
|
|
|
|
is a struct with the following elements
|
|
|
|
.sp
|
2007-12-07 19:53:58 +00:00
|
|
|
.RS 4
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
siginfo_t {
|
2007-07-17 18:49:30 +00:00
|
|
|
.\" FIXME si_tid and si_overrun are not documented.
|
2007-07-17 18:53:09 +00:00
|
|
|
.\" FIXME si_trapno is not documented; is it actually used?
|
2007-04-05 13:29:41 +00:00
|
|
|
int si_signo; /* Signal number */
|
|
|
|
int si_errno; /* An errno value */
|
|
|
|
int si_code; /* Signal code */
|
|
|
|
pid_t si_pid; /* Sending process ID */
|
|
|
|
uid_t si_uid; /* Real user ID of sending process */
|
|
|
|
int si_status; /* Exit value or signal */
|
|
|
|
clock_t si_utime; /* User time consumed */
|
|
|
|
clock_t si_stime; /* System time consumed */
|
|
|
|
sigval_t si_value; /* Signal value */
|
|
|
|
int si_int; /* POSIX.1b signal */
|
|
|
|
void *si_ptr; /* POSIX.1b signal */
|
|
|
|
void *si_addr; /* Memory location which caused fault */
|
|
|
|
int si_band; /* Band event */
|
|
|
|
int si_fd; /* File descriptor */
|
2004-11-03 13:51:07 +00:00
|
|
|
}
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.IR si_signo ", " si_errno " and " si_code
|
|
|
|
are defined for all signals.
|
2007-07-14 03:08:42 +00:00
|
|
|
.RI ( si_errno
|
2005-11-28 16:17:54 +00:00
|
|
|
is unused on Linux.)
|
2004-11-03 13:51:07 +00:00
|
|
|
The rest of the struct may be a union, so that one should only
|
2007-05-04 20:32:14 +00:00
|
|
|
read the fields that are meaningful for the given signal:
|
|
|
|
.IP * 2
|
2004-11-18 13:37:14 +00:00
|
|
|
POSIX.1b signals and
|
|
|
|
.B SIGCHLD
|
|
|
|
fill in
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR si_pid " and " si_uid .
|
2007-04-12 22:42:49 +00:00
|
|
|
.BR
|
2007-05-04 20:32:14 +00:00
|
|
|
.IP *
|
2004-11-18 13:37:14 +00:00
|
|
|
.B SIGCHLD
|
|
|
|
also fills in
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR si_status ", " si_utime " and " si_stime .
|
2007-05-04 20:32:14 +00:00
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR si_int " and " si_ptr
|
|
|
|
are specified by the sender of the POSIX.1b signal.
|
2007-05-04 20:32:14 +00:00
|
|
|
See
|
|
|
|
.BR sigqueue (2)
|
|
|
|
for more details.
|
|
|
|
.IP *
|
2007-04-12 22:42:49 +00:00
|
|
|
.BR SIGILL ,
|
2004-11-18 13:37:14 +00:00
|
|
|
.BR SIGFPE ,
|
2007-04-12 22:42:49 +00:00
|
|
|
.BR SIGSEGV ,
|
2004-11-18 13:37:14 +00:00
|
|
|
and
|
|
|
|
.B SIGBUS
|
|
|
|
fill in
|
2004-11-03 13:51:07 +00:00
|
|
|
.I si_addr
|
|
|
|
with the address of the fault.
|
2004-11-18 13:37:14 +00:00
|
|
|
.B SIGPOLL
|
|
|
|
fills in
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR si_band " and " si_fd .
|
2007-05-04 20:32:14 +00:00
|
|
|
.PP
|
2004-11-03 13:51:07 +00:00
|
|
|
.I si_code
|
2007-06-29 17:32:54 +00:00
|
|
|
is a value (not a bit mask)
|
|
|
|
indicating why this signal was sent.
|
2007-10-16 19:18:17 +00:00
|
|
|
The following list shows the values which can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for any signal, along with reason that the signal was generated.
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B SI_USER
|
|
|
|
.BR kill (2)
|
|
|
|
or
|
|
|
|
.BR raise (3)
|
|
|
|
.TP
|
|
|
|
.B SI_KERNEL
|
|
|
|
Sent by the kernel.
|
|
|
|
.TP
|
|
|
|
.B SI_QUEUE
|
|
|
|
.BR sigqueue (2)
|
|
|
|
.TP
|
|
|
|
.B SI_TIMER
|
|
|
|
POSIX timer expired
|
|
|
|
.TP
|
|
|
|
.B SI_MESGQ
|
|
|
|
POSIX message queue state changed (since Linux 2.6.6); see
|
|
|
|
.BR mq_notify (3)
|
|
|
|
.TP
|
|
|
|
.B SI_ASYNCIO
|
|
|
|
AIO completed
|
|
|
|
.TP
|
|
|
|
.B SI_SIGIO
|
|
|
|
queued SIGIO
|
|
|
|
.TP
|
|
|
|
.B SI_TKILL
|
|
|
|
.BR tkill (2)
|
|
|
|
or
|
|
|
|
.BR tgkill (2)
|
|
|
|
(since Linux 2.4.19)
|
2006-02-08 09:44:13 +00:00
|
|
|
.\" SI_DETHREAD is defined in 2.6.9 sources, but isn't implemented
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" It appears to have been an idea that was tried during 2.5.6
|
2006-02-08 09:44:13 +00:00
|
|
|
.\" through to 2.5.24 and then was backed out.
|
2007-06-29 17:32:54 +00:00
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGILL
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B ILL_ILLOPC
|
|
|
|
illegal opcode
|
|
|
|
.TP
|
|
|
|
.B ILL_ILLOPN
|
|
|
|
illegal operand
|
|
|
|
.TP
|
|
|
|
.B ILL_ILLADR
|
|
|
|
illegal addressing mode
|
|
|
|
.TP
|
|
|
|
.B ILL_ILLTRP
|
|
|
|
illegal trap
|
|
|
|
.TP
|
|
|
|
.B ILL_PRVOPC
|
|
|
|
privileged opcode
|
|
|
|
.TP
|
|
|
|
.B ILL_PRVREG
|
|
|
|
privileged register
|
|
|
|
.TP
|
|
|
|
.B ILL_COPROC
|
|
|
|
coprocessor error
|
|
|
|
.TP
|
|
|
|
.B ILL_BADSTK
|
|
|
|
internal stack error
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGFPE
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B FPE_INTDIV
|
|
|
|
integer divide by zero
|
|
|
|
.TP
|
|
|
|
.B FPE_INTOVF
|
|
|
|
integer overflow
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTDIV
|
|
|
|
floating point divide by zero
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTOVF
|
|
|
|
floating point overflow
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTUND
|
|
|
|
floating point underflow
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTRES
|
|
|
|
floating point inexact result
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTINV
|
|
|
|
floating point invalid operation
|
|
|
|
.TP
|
|
|
|
.B FPE_FLTSUB
|
|
|
|
subscript out of range
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGSEGV
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B SEGV_MAPERR
|
|
|
|
address not mapped to object
|
|
|
|
.TP
|
|
|
|
.B SEGV_ACCERR
|
|
|
|
invalid permissions for mapped object
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGBUS
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B BUS_ADRALN
|
|
|
|
invalid address alignment
|
|
|
|
.TP
|
|
|
|
.B BUS_ADRERR
|
|
|
|
non-existent physical address
|
|
|
|
.TP
|
|
|
|
.B BUS_OBJERR
|
|
|
|
object specific hardware error
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGTRAP
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B TRAP_BRKPT
|
|
|
|
process breakpoint
|
|
|
|
.TP
|
|
|
|
.B TRAP_TRACE
|
|
|
|
process trace trap
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
2007-08-27 08:06:54 +00:00
|
|
|
.B SIGCHLD
|
2007-06-29 17:32:54 +00:00
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B CLD_EXITED
|
|
|
|
child has exited
|
|
|
|
.TP
|
|
|
|
.B CLD_KILLED
|
|
|
|
child was killed
|
|
|
|
.TP
|
|
|
|
.B CLD_DUMPED
|
|
|
|
child terminated abnormally
|
|
|
|
.TP
|
|
|
|
.B CLD_TRAPPED
|
|
|
|
traced child has trapped
|
|
|
|
.TP
|
|
|
|
.B CLD_STOPPED
|
|
|
|
child has stopped
|
|
|
|
.TP
|
|
|
|
.B CLD_CONTINUED
|
|
|
|
stopped child has continued (since Linux 2.6.9)
|
|
|
|
.RE
|
|
|
|
.PP
|
2007-10-16 19:18:17 +00:00
|
|
|
The following values can be placed in
|
2007-06-29 17:32:54 +00:00
|
|
|
.I si_code
|
|
|
|
for a
|
|
|
|
.B SIGPOLL
|
|
|
|
signal:
|
|
|
|
.RS 4
|
|
|
|
.TP 15
|
|
|
|
.B POLL_IN
|
|
|
|
data input available
|
|
|
|
.TP
|
|
|
|
.B POLL_OUT
|
|
|
|
output buffers available
|
|
|
|
.TP
|
|
|
|
.B POLL_MSG
|
|
|
|
input message available
|
|
|
|
.TP
|
|
|
|
.B POLL_ERR
|
|
|
|
i/o error
|
|
|
|
.TP
|
|
|
|
.B POLL_PRI
|
|
|
|
high priority input available
|
|
|
|
.TP
|
|
|
|
.B POLL_HUP
|
|
|
|
device disconnected
|
|
|
|
.RE
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
2005-09-15 11:47:39 +00:00
|
|
|
.BR sigaction ()
|
|
|
|
returns 0 on success and \-1 on error.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.B EFAULT
|
2005-09-15 11:47:39 +00:00
|
|
|
.IR act " or " oldact
|
|
|
|
points to memory which is not a valid part of the process address space.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2007-04-12 22:42:49 +00:00
|
|
|
An invalid signal was specified.
|
|
|
|
This will also be generated if an attempt
|
2004-11-03 13:51:07 +00:00
|
|
|
is made to change the action for
|
|
|
|
.BR SIGKILL " or " SIGSTOP ", "
|
2005-09-15 11:47:39 +00:00
|
|
|
which cannot be caught or ignored.
|
2007-05-18 16:30:46 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
POSIX.1-2001, SVr4.
|
|
|
|
.\" SVr4 does not document the EINTR condition.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
|
|
|
.PP
|
2007-06-08 09:56:56 +00:00
|
|
|
According to POSIX, the behavior of a process is undefined after it
|
2004-11-18 13:37:14 +00:00
|
|
|
ignores a
|
|
|
|
.BR SIGFPE ,
|
|
|
|
.BR SIGILL ,
|
|
|
|
or
|
2007-09-20 16:26:31 +00:00
|
|
|
.B SIGSEGV
|
2004-11-18 13:37:14 +00:00
|
|
|
signal that was not generated by
|
2007-05-11 23:07:02 +00:00
|
|
|
.BR kill (2)
|
2004-11-18 13:37:14 +00:00
|
|
|
or
|
2007-05-11 23:07:02 +00:00
|
|
|
.BR raise (3).
|
2004-11-03 13:51:07 +00:00
|
|
|
Integer division by zero has undefined result.
|
2004-11-18 13:37:14 +00:00
|
|
|
On some architectures it will generate a
|
|
|
|
.B SIGFPE
|
|
|
|
signal.
|
2007-06-21 05:38:48 +00:00
|
|
|
(Also dividing the most negative integer by \-1 may generate
|
|
|
|
.BR SIGFPE .)
|
2004-11-03 13:51:07 +00:00
|
|
|
Ignoring this signal might lead to an endless loop.
|
|
|
|
.PP
|
2004-11-18 13:37:14 +00:00
|
|
|
POSIX.1-1990 disallowed setting the action for
|
|
|
|
.B SIGCHLD
|
|
|
|
to
|
|
|
|
.BR SIG_IGN .
|
|
|
|
POSIX.1-2001 allows this possibility, so that ignoring
|
|
|
|
.B SIGCHLD
|
|
|
|
can be used to prevent the creation of zombies (see
|
|
|
|
.BR wait (2)).
|
2007-06-08 09:56:56 +00:00
|
|
|
Nevertheless, the historical BSD and System V behaviors for ignoring
|
2004-11-18 13:37:14 +00:00
|
|
|
.B SIGCHLD
|
|
|
|
differ, so that the only completely portable method of ensuring that
|
|
|
|
terminated children do not become zombies is to catch the
|
|
|
|
.B SIGCHLD
|
|
|
|
signal and perform a
|
|
|
|
.BR wait (2)
|
|
|
|
or similar.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2004-11-18 13:37:14 +00:00
|
|
|
POSIX.1-1990 only specified
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR SA_NOCLDSTOP .
|
2004-11-18 13:37:14 +00:00
|
|
|
POSIX.1-2001 added
|
|
|
|
.BR SA_NOCLDWAIT ,
|
|
|
|
.BR SA_RESETHAND ,
|
|
|
|
.BR SA_NODEFER ,
|
|
|
|
and
|
|
|
|
.BR SA_SIGINFO .
|
|
|
|
Use of these latter values in
|
2004-11-03 13:51:07 +00:00
|
|
|
.I sa_flags
|
2004-11-18 13:37:14 +00:00
|
|
|
may be less portable in applications intended for older
|
|
|
|
Unix implementations.
|
|
|
|
.PP
|
|
|
|
Support for
|
|
|
|
.B SA_SIGINFO
|
|
|
|
was added in Linux 2.2.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.B SA_RESETHAND
|
|
|
|
flag is compatible with the SVr4 flag of the same name.
|
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.B SA_NODEFER
|
|
|
|
flag is compatible with the SVr4 flag of the same name under kernels
|
2007-04-12 22:42:49 +00:00
|
|
|
1.3.9 and newer.
|
|
|
|
On older kernels the Linux implementation
|
2004-11-03 13:51:07 +00:00
|
|
|
allowed the receipt of any signal, not just the one we are installing
|
|
|
|
(effectively overriding any
|
|
|
|
.I sa_mask
|
|
|
|
settings).
|
2005-09-15 11:47:39 +00:00
|
|
|
.\".PP
|
|
|
|
.\"The
|
|
|
|
.\".BR SA_RESETHAND " and " SA_NODEFER
|
|
|
|
.\"names for SVr4 compatibility are present only in library versions 3.0.9
|
|
|
|
.\"and greater.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2004-11-18 13:37:14 +00:00
|
|
|
.BR sigaction ()
|
2004-11-03 13:51:07 +00:00
|
|
|
can be called with a null second argument to query the current signal
|
2007-04-12 22:42:49 +00:00
|
|
|
handler.
|
|
|
|
It can also be used to check whether a given signal is valid for
|
2004-11-03 13:51:07 +00:00
|
|
|
the current machine by calling it with null second and third arguments.
|
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
It is not possible to block
|
2005-09-15 11:47:39 +00:00
|
|
|
.BR SIGKILL " or " SIGSTOP
|
|
|
|
(by specifying them in
|
|
|
|
.IR sa_mask ).
|
|
|
|
Attempts to do so are silently ignored.
|
|
|
|
.PP
|
2004-11-03 13:51:07 +00:00
|
|
|
See
|
|
|
|
.BR sigsetops (3)
|
|
|
|
for details on manipulating signal sets.
|
2007-05-04 20:32:14 +00:00
|
|
|
.PP
|
|
|
|
See
|
|
|
|
.BR signal (7)
|
2007-06-21 22:55:04 +00:00
|
|
|
for a list of the async-signal-safe functions that can be
|
2007-05-04 20:32:14 +00:00
|
|
|
safely called inside from inside a signal handler.
|
2007-05-16 03:03:15 +00:00
|
|
|
.SS Undocumented
|
|
|
|
Before the introduction of
|
|
|
|
.B SA_SIGINFO
|
|
|
|
it was also possible to get some additional information,
|
|
|
|
namely by using a
|
|
|
|
.I sa_handler
|
|
|
|
with second argument of type
|
|
|
|
.IR "struct sigcontext".
|
|
|
|
See the relevant kernel sources for details.
|
|
|
|
This use is obsolete now.
|
2005-09-15 11:47:39 +00:00
|
|
|
.SH BUGS
|
|
|
|
In kernels up to and including 2.6.13, specifying
|
|
|
|
.B SA_NODEFER
|
|
|
|
in
|
|
|
|
.I sa_flags
|
2007-06-28 19:04:25 +00:00
|
|
|
prevents not only the delivered signal from being masked during
|
2005-09-15 11:47:39 +00:00
|
|
|
execution of the handler, but also the signals specified in
|
|
|
|
.IR sa_mask .
|
2007-06-23 08:16:35 +00:00
|
|
|
This bug was fixed in kernel 2.6.14.
|
2007-05-25 18:42:55 +00:00
|
|
|
.SH EXAMPLE
|
|
|
|
See
|
|
|
|
.BR mprotect (2).
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR kill (1),
|
|
|
|
.BR kill (2),
|
2007-07-08 15:05:14 +00:00
|
|
|
.BR killpg (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR pause (2),
|
|
|
|
.BR sigaltstack (2),
|
|
|
|
.BR signal (2),
|
2005-09-15 11:47:39 +00:00
|
|
|
.BR sigpending (2),
|
|
|
|
.BR sigprocmask (2),
|
2004-11-11 14:09:54 +00:00
|
|
|
.BR sigqueue (2),
|
2005-09-15 11:47:39 +00:00
|
|
|
.BR sigsuspend (2),
|
2004-11-18 13:37:14 +00:00
|
|
|
.BR wait (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR raise (3),
|
|
|
|
.BR siginterrupt (3),
|
|
|
|
.BR sigsetops (3),
|
2005-11-29 15:01:54 +00:00
|
|
|
.BR sigvec (3),
|
2006-03-31 07:10:17 +00:00
|
|
|
.BR core (5),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR signal (7)
|