man-pages/man0p/signal.h.0p

789 lines
15 KiB
Plaintext

.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "<signal.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <signal.h>
.SH NAME
signal.h \- signals
.SH SYNOPSIS
.LP
\fB#include <signal.h>\fP
.SH DESCRIPTION
.LP
Some of the functionality described on this reference page extends
the ISO\ C standard. Applications shall define
the appropriate feature test macro (see the System Interfaces volume
of IEEE\ Std\ 1003.1-2001, Section 2.2, The Compilation Environment)
to enable the visibility of these symbols in this
header.
.LP
The \fI<signal.h>\fP header shall define the following symbolic constants,
each of which expands to a distinct constant
expression of the type:
.sp
.RS
.nf
\fBvoid (*)(int)
\fP
.fi
.RE
.LP
whose value matches no declarable function.
.TP 7
SIG_DFL
Request for default signal handling.
.TP 7
SIG_ERR
Return value from \fIsignal\fP() in case of error.
.TP 7
SIG_HOLD
Request that signal be held.
.TP 7
SIG_IGN
Request that signal be ignored.
.sp
.LP
The following data types shall be defined through \fBtypedef\fP:
.TP 7
\fBsig_atomic_t\fP
Possibly volatile-qualified integer type of an object that can be
accessed as an atomic entity, even in the presence of
asynchronous interrupts.
.TP 7
\fBsigset_t\fP
Integer or structure type of an object used to represent sets of signals.
.TP 7
\fBpid_t\fP
As
described in \fI<sys/types.h>\fP .
.sp
.LP
The \fI<signal.h>\fP header shall define the \fBsigevent\fP structure,
which has at least the following members:
.sp
.RS
.nf
\fBint sigev_notify \fP Notification type. \fB
int sigev_signo \fP Signal number. \fB
union sigval sigev_value \fP Signal value. \fB
void(*)(union sigval) sigev_notify_function \fP Notification function. \fB
(pthread_attr_t *) sigev_notify_attributes\fP Notification attributes. \fB
\fP
.fi
.RE
.LP
The following values of \fIsigev_notify\fP shall be defined:
.TP 7
SIGEV_NONE
No asynchronous notification is delivered when the event of interest
occurs.
.TP 7
SIGEV_SIGNAL
A queued signal, with an application-defined value, is generated when
the event of interest occurs.
.TP 7
SIGEV_THREAD
A notification function is called to perform notification.
.sp
.LP
The \fBsigval\fP union shall be defined as:
.sp
.RS
.nf
\fBint sival_int \fP Integer signal value. \fB
void *sival_ptr \fP Pointer signal value. \fB
\fP
.fi
.RE
.LP
This header shall also declare the macros SIGRTMIN and SIGRTMAX, which
evaluate to integer expressions, and specify a range of
signal numbers that are reserved for application use and for which
the realtime signal behavior specified in this volume of
IEEE\ Std\ 1003.1-2001 is supported. The signal numbers in this range
do not overlap any of the signals specified in the
following table.
.LP
The range SIGRTMIN through SIGRTMAX inclusive shall include at least
{RTSIG_MAX} signal numbers.
.LP
It is implementation-defined whether realtime signal behavior is supported
for other signals.
.LP
This header also declares the constants that are used to refer to
the signals that occur in the system. Signals defined here
begin with the letters SIG. Each of the signals have distinct positive
integer values. The value 0 is reserved for use as the null
signal (see \fIkill\fP()). Additional implementation-defined signals
may occur in the
system.
.LP
The
ISO\ C standard only requires the signal names SIGABRT, SIGFPE, SIGILL,
SIGINT, SIGSEGV, and SIGTERM to be defined.
.LP
The following signals shall be supported on all implementations (default
actions are explained below the table):
.TS C
center; l1 l1 lw(40).
\fBSignal\fP \fBDefault Action\fP T{
.na
\fBDescription\fP
.ad
T}
SIGABRT A T{
.na
Process abort signal.
.ad
T}
SIGALRM T T{
.na
Alarm clock.
.ad
T}
SIGBUS A T{
.na
Access to an undefined portion of a memory object.
.ad
T}
SIGCHLD I T{
.na
Child process terminated, stopped,
.ad
T}
\ \ T{
.na
or continued.
.ad
T}
SIGCONT C T{
.na
Continue executing, if stopped.
.ad
T}
SIGFPE A T{
.na
Erroneous arithmetic operation.
.ad
T}
SIGHUP T T{
.na
Hangup.
.ad
T}
SIGILL A T{
.na
Illegal instruction.
.ad
T}
SIGINT T T{
.na
Terminal interrupt signal.
.ad
T}
SIGKILL T T{
.na
Kill (cannot be caught or ignored).
.ad
T}
SIGPIPE T T{
.na
Write on a pipe with no one to read it.
.ad
T}
SIGQUIT A T{
.na
Terminal quit signal.
.ad
T}
SIGSEGV A T{
.na
Invalid memory reference.
.ad
T}
SIGSTOP S T{
.na
Stop executing (cannot be caught or ignored).
.ad
T}
SIGTERM T T{
.na
Termination signal.
.ad
T}
SIGTSTP S T{
.na
Terminal stop signal.
.ad
T}
SIGTTIN S T{
.na
Background process attempting read.
.ad
T}
SIGTTOU S T{
.na
Background process attempting write.
.ad
T}
SIGUSR1 T T{
.na
User-defined signal 1.
.ad
T}
SIGUSR2 T T{
.na
User-defined signal 2.
.ad
T}
SIGPOLL T T{
.na
Pollable event.
.ad
T}
SIGPROF T T{
.na
Profiling timer expired.
.ad
T}
SIGSYS A T{
.na
Bad system call.
.ad
T}
SIGTRAP A T{
.na
Trace/breakpoint trap.
.ad
T}
SIGURG I T{
.na
High bandwidth data is available at a socket.
.ad
T}
SIGVTALRM T T{
.na
Virtual timer expired.
.ad
T}
SIGXCPU A T{
.na
CPU time limit exceeded.
.ad
T}
SIGXFSZ A T{
.na
File size limit exceeded.
.ad
T}
.TE
.LP
The default actions are as follows:
.TP 7
T
Abnormal termination of the process. The process is terminated with
all the consequences of \fI_exit\fP() except that the status made
available to \fIwait\fP() and \fIwaitpid\fP() indicates abnormal
termination by the specified signal.
.TP 7
A
Abnormal termination of the process.
.br
Additionally, implementation-defined abnormal termination actions,
such as creation of a \fBcore\fP file, may occur.
.TP 7
I
Ignore the signal.
.TP 7
S
Stop the process.
.TP 7
C
Continue the process, if it is stopped; otherwise, ignore the signal.
.sp
.sp
.LP
The
header shall provide a declaration of \fBstruct sigaction\fP, including
at least the following members:
.sp
.RS
.nf
\fBvoid (*sa_handler)(int) \fP Pointer to a signal-catching function or one of the macros \fB
\fP SIG_IGN or SIG_DFL. \fB
sigset_t sa_mask \fP Set of signals to be blocked during execution of the signal \fB
\fP handling function. \fB
int sa_flags \fP Special flags. \fB
void (*sa_sigaction)(int, siginfo_t *, void *)
\fP Pointer to a signal-catching function. \fB
\fP
.fi
.RE
.LP
The storage occupied by \fIsa_handler\fP and \fIsa_sigaction\fP may
overlap, and a conforming application shall not use both
simultaneously.
.LP
The following shall be declared as constants:
.TP 7
SA_NOCLDSTOP
Do
not generate SIGCHLD when children stop
.br
or
stopped children continue.
.TP 7
SIG_BLOCK
The resulting set is the union of the current set and the signal set
pointed to by the argument \fIset\fP.
.TP 7
SIG_UNBLOCK
The resulting set is the intersection of the current set and the complement
of the signal set pointed to by the argument
\fIset\fP.
.TP 7
SIG_SETMASK
The resulting set is the signal set pointed to by the argument \fIset\fP.
.TP 7
SA_ONSTACK
Causes signal delivery to occur on an alternate stack.
.TP 7
SA_RESETHAND
Causes signal dispositions to be set to SIG_DFL on entry to signal
handlers.
.TP 7
SA_RESTART
Causes certain functions to become restartable.
.TP 7
SA_SIGINFO
Causes extra information to be passed to signal handlers at the time
of receipt of a signal.
.TP 7
SA_NOCLDWAIT
Causes implementations not to create zombie processes on child death.
.TP 7
SA_NODEFER
Causes signal not to be automatically blocked on entry to signal handler.
.TP 7
SS_ONSTACK
Process is executing on an alternate signal stack.
.TP 7
SS_DISABLE
Alternate signal stack is disabled.
.TP 7
MINSIGSTKSZ
Minimum stack size for a signal handler.
.TP 7
SIGSTKSZ
Default size in bytes for the alternate signal stack.
.sp
.LP
The \fBucontext_t\fP structure shall be defined through \fBtypedef\fP
as described in \fI<ucontext.h>\fP.
.LP
The \fBmcontext_t\fP type shall be defined through \fBtypedef\fP as
described in \fI<ucontext.h>\fP.
.LP
The \fI<signal.h>\fP header shall define the \fBstack_t\fP type as
a structure that includes at least the following
members:
.sp
.RS
.nf
\fBvoid *ss_sp \fP Stack base or pointer. \fB
size_t ss_size \fP Stack size. \fB
int ss_flags \fP Flags. \fB
\fP
.fi
.RE
.LP
The \fI<signal.h>\fP header shall define the \fBsigstack\fP structure
that includes at least the following members:
.sp
.RS
.nf
\fBint ss_onstack \fP Non-zero when signal stack is in use. \fB
void *ss_sp \fP Signal stack pointer. \fB
\fP
.fi
.RE
.LP
The
\fI<signal.h>\fP header shall define the \fBsiginfo_t\fP type as a
structure that includes at least the following members:
.sp
.RS
.nf
\fB
int si_signo \fP Signal number. \fB
int si_errno \fP If non-zero, an \fIerrno\fP value associated with \fB
\fP this signal, as defined in \fB<errno.h>.\fP \fB
int si_code \fP Signal code. \fB
pid_t si_pid \fP Sending process ID. \fB
uid_t si_uid \fP Real user ID of sending process. \fB
void *si_addr \fP Address of faulting instruction. \fB
int si_status\fP Exit value or signal. \fB
long si_band \fP Band event for SIGPOLL. \fB
union sigval si_value \fP Signal value. \fB
\fP
.fi
.RE
.LP
The macros specified in the \fBCode\fP column of the following table
are defined for use as values of \fIsi_code\fP that are
\ signal-specific or non-signal-specific reasons why the signal
was generated.
.TS C
center; l l lw(40).
\fBSignal\fP \fBCode\fP T{
.na
\fBReason\fP
.ad
T}
SIGILL ILL_ILLOPC T{
.na
Illegal opcode.
.ad
T}
\ ILL_ILLOPN T{
.na
Illegal operand.
.ad
T}
\ ILL_ILLADR T{
.na
Illegal addressing mode.
.ad
T}
\ ILL_ILLTRP T{
.na
Illegal trap.
.ad
T}
\ ILL_PRVOPC T{
.na
Privileged opcode.
.ad
T}
\ ILL_PRVREG T{
.na
Privileged register.
.ad
T}
\ ILL_COPROC T{
.na
Coprocessor error.
.ad
T}
\ ILL_BADSTK T{
.na
Internal stack error.
.ad
T}
SIGFPE FPE_INTDIV T{
.na
Integer divide by zero.
.ad
T}
\ FPE_INTOVF T{
.na
Integer overflow.
.ad
T}
\ FPE_FLTDIV T{
.na
Floating-point divide by zero.
.ad
T}
\ FPE_FLTOVF T{
.na
Floating-point overflow.
.ad
T}
\ FPE_FLTUND T{
.na
Floating-point underflow.
.ad
T}
\ FPE_FLTRES T{
.na
Floating-point inexact result.
.ad
T}
\ FPE_FLTINV T{
.na
Invalid floating-point operation.
.ad
T}
\ FPE_FLTSUB T{
.na
Subscript out of range.
.ad
T}
SIGSEGV SEGV_MAPERR T{
.na
Address not mapped to object.
.ad
T}
\ SEGV_ACCERR T{
.na
Invalid permissions for mapped object.
.ad
T}
SIGBUS BUS_ADRALN T{
.na
Invalid address alignment.
.ad
T}
\ BUS_ADRERR T{
.na
Nonexistent physical address.
.ad
T}
\ BUS_OBJERR T{
.na
Object-specific hardware error.
.ad
T}
SIGTRAP TRAP_BRKPT T{
.na
Process breakpoint.
.ad
T}
\ TRAP_TRACE T{
.na
Process trace trap.
.ad
T}
SIGCHLD CLD_EXITED T{
.na
Child has exited.
.ad
T}
\ CLD_KILLED T{
.na
Child has terminated abnormally and did not create a \fBcore\fP file.
.ad
T}
\ CLD_DUMPED T{
.na
Child has terminated abnormally and created a \fBcore\fP file.
.ad
T}
\ CLD_TRAPPED T{
.na
Traced child has trapped.
.ad
T}
\ CLD_STOPPED T{
.na
Child has stopped.
.ad
T}
\ CLD_CONTINUED T{
.na
Stopped child has continued.
.ad
T}
SIGPOLL POLL_IN T{
.na
Data input available.
.ad
T}
\ POLL_OUT T{
.na
Output buffers available.
.ad
T}
\ POLL_MSG T{
.na
Input message available.
.ad
T}
\ POLL_ERR T{
.na
I/O error.
.ad
T}
\ POLL_PRI T{
.na
High priority input available.
.ad
T}
\ POLL_HUP T{
.na
Device disconnected.
.ad
T}
Any SI_USER T{
.na
Signal sent by \fIkill\fP().
.ad
T}
\ SI_QUEUE T{
.na
Signal sent by the \fIsigqueue\fP().
.ad
T}
\ SI_TIMER T{
.na
Signal generated by expiration of a timer set by \fItimer_settime\fP().
.ad
T}
\ SI_ASYNCIO T{
.na
Signal generated by completion of an asynchronous I/O request.
.ad
T}
\ SI_MESGQ T{
.na
Signal generated by arrival of a message on an empty message queue.
.ad
T}
.TE
.LP
Implementations may support additional \fIsi_code\fP values not included
in this list, may generate values included in this list
under circumstances other than those described in this list, and may
contain extensions or limitations that prevent some values
from being generated. Implementations do not generate a different
value from the ones described in this list for circumstances
described in this list.
.LP
In addition, the following signal-specific information shall be available:
.TS C
center; l1 l1 l.
\fBSignal\fP \fBMember\fP \fBValue\fP
SIGILL \fBvoid * \fIsi_addr\fP\fP Address of faulting instruction.
SIGFPE \fB\ \fP \
SIGSEGV \fBvoid * \fIsi_addr\fP\fP Address of faulting memory reference.
SIGBUS \fB\ \fP \
SIGCHLD \fBpid_t \fIsi_pid\fP\fP Child process ID.
\ \fBint \fIsi_status\fP\fP Exit value or signal.
\ \fBuid_t \fIsi_uid\fP\fP Real user ID of the process that sent the signal.
SIGPOLL \fBlong \fIsi_band\fP\fP Band event for POLL_IN, POLL_OUT, or POLL_MSG.
.TE
.LP
For some implementations, the value of \fIsi_addr\fP may be inaccurate.
.LP
The following shall be declared as functions and may also be defined
as macros:
.sp
.RS
.nf
\fB
void (*bsd_signal(int, void (*)(int)))(int);
int kill(pid_t, int);
int killpg(pid_t, int);
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, const sigset_t *, sigset_t *);
int raise(int);
int sigaction(int, const struct sigaction *restrict,
struct sigaction *restrict);
int sigaddset(sigset_t *, int);
int sigaltstack(const stack_t *restrict, stack_t *restrict);
int sigdelset(sigset_t *, int);
int sigemptyset(sigset_t *);
int sigfillset(sigset_t *);
int sighold(int);
int sigignore(int);
int siginterrupt(int, int);
int sigismember(const sigset_t *, int);
void (*signal(int, void (*)(int)))(int);
int sigpause(int);
int sigpending(sigset_t *);
int sigprocmask(int, const sigset_t *restrict, sigset_t *restrict);
int sigqueue(pid_t, int, const union sigval);
int sigrelse(int);
void (*sigset(int, void (*)(int)))(int);
int sigsuspend(const sigset_t *);
int sigtimedwait(const sigset_t *restrict, siginfo_t *restrict,
const struct timespec *restrict);
int sigwait(const sigset_t *restrict, int *restrict);
int sigwaitinfo(const sigset_t *restrict, siginfo_t *restrict);
\fP
.fi
.RE
.LP
Inclusion of the \fI<signal.h>\fP header may make visible all symbols
from the \fI<time.h>\fP header.
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<errno.h>\fP , \fI<stropts.h>\fP , \fI<sys/types.h>\fP , \fI<time.h>\fP
, \fI<ucontext.h>\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001,
\fIalarm\fP(), \fIbsd_signal\fP(), \fIioctl\fP(), \fIkill\fP(), \fIkillpg\fP(),
\fIraise\fP(), \fIsigaction\fP(), \fIsigaddset\fP(), \fIsigaltstack\fP(),
\fIsigdelset\fP(), \fIsigemptyset\fP(), \fIsigfillset\fP(), \fIsiginterrupt\fP(),
\fIsigismember\fP(), \fIsignal\fP(), \fIsigpending\fP(), \fIsigprocmask\fP(),
\fIsigqueue\fP(), \fIsigsuspend\fP(), \fIsigwaitinfo\fP(), \fIwait\fP(),
\fIwaitid\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .