man signal.h () - signals

NAME

signal.h - signals

SYNOPSIS

#include <signal.h>

DESCRIPTION

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.

The <signal.h> header shall define the following symbolic constants, each of which expands to a distinct constant expression of the type:

void (*)(int)

whose value matches no declarable function.

SIG_DFL
Request for default signal handling.
SIG_ERR
Return value from signal() in case of error.
SIG_HOLD
Request that signal be held.
SIG_IGN
Request that signal be ignored.

The following data types shall be defined through typedef:

sig_atomic_t
Possibly volatile-qualified integer type of an object that can be accessed as an atomic entity, even in the presence of asynchronous interrupts.
sigset_t
Integer or structure type of an object used to represent sets of signals.
pid_t
As described in <sys/types.h> .

The <signal.h> header shall define the sigevent structure, which has at least the following members:

int sigev_notify Notification type. int sigev_signo Signal number. union sigval sigev_value Signal value. void(*)(union sigval) sigev_notify_function Notification function. (pthread_attr_t *) sigev_notify_attributes Notification attributes.

The following values of sigev_notify shall be defined:

SIGEV_NONE
No asynchronous notification is delivered when the event of interest occurs.
SIGEV_SIGNAL
A queued signal, with an application-defined value, is generated when the event of interest occurs.
SIGEV_THREAD
A notification function is called to perform notification.

The sigval union shall be defined as:

int sival_int Integer signal value. void *sival_ptr Pointer signal value.

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.

The range SIGRTMIN through SIGRTMAX inclusive shall include at least {RTSIG_MAX} signal numbers.

It is implementation-defined whether realtime signal behavior is supported for other signals.

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 kill()). Additional implementation-defined signals may occur in the system.

The ISO C standard only requires the signal names SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, and SIGTERM to be defined.

The following signals shall be supported on all implementations (default actions are explained below the table): center; l1 l1 lw(4). Signal Default Action T{ Description T} SIGABRT A T{ Process abort signal. T} SIGALRM T T{ Alarm clock. T} SIGBUS A T{ Access to an undefined portion of a memory object. T} SIGCHLD I T{ Child process terminated, stopped, T} T{ or continued. T} SIGCONT C T{ Continue executing, if stopped. T} SIGFPE A T{ Erroneous arithmetic operation. T} SIGHUP T T{ Hangup. T} SIGILL A T{ Illegal instruction. T} SIGINT T T{ Terminal interrupt signal. T} SIGKILL T T{ Kill (cannot be caught or ignored). T} SIGPIPE T T{ Write on a pipe with no one to read it. T} SIGQUIT A T{ Terminal quit signal. T} SIGSEGV A T{ Invalid memory reference. T} SIGSTOP S T{ Stop executing (cannot be caught or ignored). T} SIGTERM T T{ Termination signal. T} SIGTSTP S T{ Terminal stop signal. T} SIGTTIN S T{ Background process attempting read. T} SIGTTOU S T{ Background process attempting write. T} SIGUSR1 T T{ User-defined signal 1. T} SIGUSR2 T T{ User-defined signal 2. T} SIGPOLL T T{ Pollable event. T} SIGPROF T T{ Profiling timer expired. T} SIGSYS A T{ Bad system call. T} SIGTRAP A T{ Trace/breakpoint trap. T} SIGURG I T{ High bandwidth data is available at a socket. T} SIGVTALRM T T{ Virtual timer expired. T} SIGXCPU A T{ CPU time limit exceeded. T} SIGXFSZ A T{ File size limit exceeded. T}

The default actions are as follows:

T
Abnormal termination of the process. The process is terminated with all the consequences of _exit() except that the status made available to wait() and waitpid() indicates abnormal termination by the specified signal.
A
Abnormal termination of the process.

Additionally, implementation-defined abnormal termination actions, such as creation of a core file, may occur.
I
Ignore the signal.
S
Stop the process.
C
Continue the process, if it is stopped; otherwise, ignore the signal.

The header shall provide a declaration of struct sigaction, including at least the following members:

void (*sa_handler)(int) Pointer to a signal-catching function or one of the macros SIG_IGN or SIG_DFL. sigset_t sa_mask Set of signals to be blocked during execution of the signal handling function. int sa_flags Special flags. void (*sa_sigaction)(int, siginfo_t *, void *) Pointer to a signal-catching function.

The storage occupied by sa_handler and sa_sigaction may overlap, and a conforming application shall not use both simultaneously.

The following shall be declared as constants:

SA_NOCLDSTOP
Do not generate SIGCHLD when children stop

or stopped children continue.
SIG_BLOCK
The resulting set is the union of the current set and the signal set pointed to by the argument set.
SIG_UNBLOCK
The resulting set is the intersection of the current set and the complement of the signal set pointed to by the argument set.
SIG_SETMASK
The resulting set is the signal set pointed to by the argument set.
SA_ONSTACK
Causes signal delivery to occur on an alternate stack.
SA_RESETHAND
Causes signal dispositions to be set to SIG_DFL on entry to signal handlers.
SA_RESTART
Causes certain functions to become restartable.
SA_SIGINFO
Causes extra information to be passed to signal handlers at the time of receipt of a signal.
SA_NOCLDWAIT
Causes implementations not to create zombie processes on child death.
SA_NODEFER
Causes signal not to be automatically blocked on entry to signal handler.
SS_ONSTACK
Process is executing on an alternate signal stack.
SS_DISABLE
Alternate signal stack is disabled.
MINSIGSTKSZ
Minimum stack size for a signal handler.
SIGSTKSZ
Default size in bytes for the alternate signal stack.

The ucontext_t structure shall be defined through typedef as described in <ucontext.h>.

The mcontext_t type shall be defined through typedef as described in <ucontext.h>.

The <signal.h> header shall define the stack_t type as a structure that includes at least the following members:

void *ss_sp Stack base or pointer. size_t ss_size Stack size. int ss_flags Flags.

The <signal.h> header shall define the sigstack structure that includes at least the following members:

int ss_onstack Non-zero when signal stack is in use. void *ss_sp Signal stack pointer.

The <signal.h> header shall define the siginfo_t type as a structure that includes at least the following members:

int si_signo Signal number.

int si_errno If non-zero, an errno value associated with this signal, as defined in <errno.h>.

int si_code Signal code.

pid_t si_pid Sending process ID. uid_t si_uid Real user ID of sending process. void *si_addr Address of faulting instruction. int si_status Exit value or signal. long si_band Band event for SIGPOLL.

union sigval si_value Signal value.

The macros specified in the Code column of the following table are defined for use as values of si_code that are signal-specific or non-signal-specific reasons why the signal was generated. center; l l lw(4). Signal Code T{ Reason T} SIGILL ILL_ILLOPC T{ Illegal opcode. T} ILL_ILLOPN T{ Illegal operand. T} ILL_ILLADR T{ Illegal addressing mode. T} ILL_ILLTRP T{ Illegal trap. T} ILL_PRVOPC T{ Privileged opcode. T} ILL_PRVREG T{ Privileged register. T} ILL_COPROC T{ Coprocessor error. T} ILL_BADSTK T{ Internal stack error. T} SIGFPE FPE_INTDIV T{ Integer divide by zero. T} FPE_INTOVF T{ Integer overflow. T} FPE_FLTDIV T{ Floating-point divide by zero. T} FPE_FLTOVF T{ Floating-point overflow. T} FPE_FLTUND T{ Floating-point underflow. T} FPE_FLTRES T{ Floating-point inexact result. T} FPE_FLTINV T{ Invalid floating-point operation. T} FPE_FLTSUB T{ Subscript out of range. T} SIGSEGV SEGV_MAPERR T{ Address not mapped to object. T} SEGV_ACCERR T{ Invalid permissions for mapped object. T} SIGBUS BUS_ADRALN T{ Invalid address alignment. T} BUS_ADRERR T{ Nonexistent physical address. T} BUS_OBJERR T{ Object-specific hardware error. T} SIGTRAP TRAP_BRKPT T{ Process breakpoint. T} TRAP_TRACE T{ Process trace trap. T} SIGCHLD CLD_EXITED T{ Child has exited. T} CLD_KILLED T{ Child has terminated abnormally and did not create a core file. T} CLD_DUMPED T{ Child has terminated abnormally and created a core file. T} CLD_TRAPPED T{ Traced child has trapped. T} CLD_STOPPED T{ Child has stopped. T} CLD_CONTINUED T{ Stopped child has continued. T} SIGPOLL POLL_IN T{ Data input available. T} POLL_OUT T{ Output buffers available. T} POLL_MSG T{ Input message available. T} POLL_ERR T{ I/O error. T} POLL_PRI T{ High priority input available. T} POLL_HUP T{ Device disconnected. T} Any SI_USER T{ Signal sent by kill(). T} SI_QUEUE T{ Signal sent by the sigqueue(). T} SI_TIMER T{ Signal generated by expiration of a timer set by timer_settime(). T} SI_ASYNCIO T{ Signal generated by completion of an asynchronous I/O request. T} SI_MESGQ T{ Signal generated by arrival of a message on an empty message queue. T}

Implementations may support additional si_code 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.

In addition, the following signal-specific information shall be available: center; l1 l1 l. Signal Member Value SIGILL void * si_addr Address of faulting instruction. SIGFPE SIGSEGV void * si_addr Address of faulting memory reference. SIGBUS SIGCHLD pid_t si_pid Child process ID. int si_status Exit value or signal. uid_t si_uid Real user ID of the process that sent the signal. SIGPOLL long si_band Band event for POLL_IN, POLL_OUT, or POLL_MSG.

For some implementations, the value of si_addr may be inaccurate.

The following shall be declared as functions and may also be defined as macros:

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);

Inclusion of the <signal.h> header may make visible all symbols from the <time.h> header.

The following sections are informative.

APPLICATION USAGE

None.

RATIONALE

None.

FUTURE DIRECTIONS

None.

SEE ALSO

<errno.h> , <stropts.h> , <sys/types.h> , <time.h> , <ucontext.h> , the System Interfaces volume of IEEE Std 1003.1-2001, alarm(), bsd_signal(), ioctl(), kill(), killpg(), raise(), sigaction(), sigaddset(), sigaltstack(), sigdelset(), sigemptyset(), sigfillset(), siginterrupt(), sigismember(), signal(), sigpending(), sigprocmask(), sigqueue(), sigsuspend(), sigwaitinfo(), wait(), waitid()

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 .