signal.h - signals
#include <signal.h>
The <signal.h> header defines 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 are defined through typedef:
- sig_atomic_t
- Integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous interrupts
- sigset_t
- Integral or structure type of an object used to represent sets of signals.
- pid_t
- As described in <sys/types.h>.
The <signal.h> header defines 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 are defined:
- SIGEV_NONE
- No asynchronous notification will be delivered when the event of interest occurs.
- SIGEV_SIGNAL
- A queued signal, with an application-defined value, will be generated when the event of interest occurs.
- SIGEV_THREAD
- A notification function will be called to perform notification.
The sigval union is defined as:
int sival_int integer signal value void* sival_ptr pointer signal value
This header also declares the macros SIGRTMIN and SIGRTMAX, which evaluate to integral expressions and, if the Realtime Signals Extension option is supported, specify a range of signal numbers that are reserved for application use and for which the realtime signal behaviour specified in this specification 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 includes at least RTSIG_MAX signal numbers.
It is implementation-dependent whether realtime signal behaviour 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 integral values. The value 0 is reserved for use as the null signal (see kill()). Additional implementation-dependent signals may occur in the system.
The following signals are supported on all implementations (default actions are explained below the table):
Signal Default Action Description SIGABRT ii Process abort signal. SIGALRM i Alarm clock. SIGFPE ii Erroneous arithmetic operation. SIGHUP i Hangup. SIGILL ii Illegal instruction. SIGINT i Terminal interrupt signal. SIGKILL i Kill (cannot be caught or ignored). SIGPIPE i Write on a pipe with no one to read it. SIGQUIT ii Terminal quit signal. SIGSEGV ii Invalid memory reference. SIGTERM i Termination signal. SIGUSR1 i User-defined signal 1. SIGUSR2 i User-defined signal 2. SIGCHLD iii Child process terminated or stopped. SIGCONT v Continue executing, if stopped. SIGSTOP iv Stop executing (cannot be caught or ignored). SIGTSTP iv Terminal stop signal. SIGTTIN iv Background process attempting read. SIGTTOU iv Background process attempting write. SIGBUS ii Access to an undefined portion of a memory object. SIGPOLL i Pollable event. SIGPROF i Profiling timer expired. SIGSYS ii Bad system call. SIGTRAP ii Trace/breakpoint trap. SIGURG iii High bandwidth data is available at a socket. SIGVTALRM i Virtual timer expired. SIGXCPU ii CPU time limit exceeded. SIGXFSZ ii File size limit exceeded. The default actions are as follows:
- i
- 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.
- ii
- Abnormal termination of the process. Additionally, implementation-dependent abnormal termination actions, such as creation of a core file, may occur.
- iii
- Ignore the signal.
- iv
- Stop the process.
- v
- Continue the process, if it is stopped; otherwise ignore the signal.
The header provides a declaration of struct sigaction, including at least the following members:
void (*sa_handler)(int) what to do on receipt of signal sigset_t sa_mask set of signals to be blocked during execution of the signal handling function int sa_flags special flags void (*)(int, siginfo_t *, void *) sa_sigaction pointer to signal handler function or one of the macros SIG_IGN or SIG_DFL
The storage occupied by sa_handler and sa_sigaction may overlap, and a portable program must not use both simultaneously.
The following are declared as constants:
- SA_NOCLDSTOP
- Do not generate SIGCHLD when children stop.
- 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 is defined through typedef as described in <ucontext.h>.
The <signal.h> header defines 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 defines 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 defines 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 reasons why the signal was generated.
Signal Code Reason SIGILL ILL_ILLOPC illegal opcode ILL_ILLOPN illegal operand ILL_ILLADR illegal addressing mode ILL_ILLTRP illegal trap ILL_PRVOPC privileged opcode ILL_PRVREG privileged register ILL_COPROC coprocessor error ILL_BADSTK internal stack error SIGFPE FPE_INTDIV integer divide by zero FPE_INTOVF integer overflow FPE_FLTDIV floating point divide by zero FPE_FLTOVF floating point overflow FPE_FLTUND floating point underflow FPE_FLTRES floating point inexact result FPE_FLTINV invalid floating point operation FPE_FLTSUB subscript out of range SIGSEGV SEGV_MAPERR address not mapped to object SEGV_ACCERR invalid permissions for mapped object SIGBUS BUS_ADRALN invalid address alignment BUS_ADRERR non-existent physical address BUS_OBJERR object specific hardware error SIGTRAP TRAP_BRKPT process breakpoint TRAP_TRACE process trace trap SIGCHLD CLD_EXITED child has exited CLD_KILLED child has terminated abnormally and did not create a core file CLD_DUMPED child has terminated abnormally and created a core file CLD_TRAPPED traced child has trapped CLD_STOPPED child has stopped CLD_CONTINUED stopped child has continued SIGPOLL POLL_IN data input available POLL_OUT output buffers available POLL_MSG input message available POLL_ERR I/O error POLL_PRI high priority input available POLL_HUP device disconnected SI_USER signal sent by kill() SI_QUEUE signal sent by the sigqueue() SI_TIMER signal generated by expiration of a timer set by timer_settime() SI_ASYNCIO signal generated by completion of an asynchronous I/O request SI_MESGQ signal generated by arrival of a message on an empty message queue
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 will 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 will be available:
Signal Member Value SIGILL
SIGFPEvoid * si_addr address of faulting instruction SIGSEGV
SIGBUSvoid * si_addr address of faulting memory reference SIGCHLD pid_t si_pid
int si_status
uid_t si_uidchild process ID
exit value or signal
real user ID of the process that sent the signalSIGPOLL 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 are 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 *, struct sigaction *); int sigaddset(sigset_t *, int); int sigaltstack(const stack_t *, stack_t *); 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 *, sigset_t *); int sigqueue(pid_t, int, const union sigval); int sigrelse(int); void (*sigset(int, void (*)(int)))(int); int sigstack(struct sigstack *ss, struct sigstack *oss); (LEGACY) int sigsuspend(const sigset_t *); int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); int sigwait(const sigset_t *set, int *sig); int sigwaitinfo(const sigset_t *, siginfo_t *);
None.
None.
alarm(), bsd_signal(), ioctl(), kill(), killpg(), raise(), sigaction(), sigaddset(), sigaltstack(), sigdelset(), sigemptyset(), sigfillset(), siginterrupt(), sigismember(), signal(), sigpending(), sigprocmask(), sigqueue(), sigsuspend(), sigwaitinfo(), wait(), waitid(), <errno.h>, <stropts.h>, <sys/types.h>, <ucontext.h>.