The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2004 Edition
Copyright © 2001-2004 The IEEE and The Open Group, All Rights reserved.

#### NAME

> signal.h - signals

#### SYNOPSIS

> `#include <signal.h>`

#### DESCRIPTION

> [CX] 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
>   [CX] 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
>   [CX] Integer or structure type of an object used to represent sets of signals.
> pid_t
>   [CX] As described in <sys/types.h>.

> [RTS] 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.

> [CX] 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):

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

> 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.
>   [XSI] 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.

> [CX] 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.

> [XSI] 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
>   [CX] Do not generate SIGCHLD when children stop
>   [XSI] or stopped children continue.
> SIG_BLOCK
>   [CX] The resulting set is the union of the current set and the signal set pointed to by the argument set.
> SIG_UNBLOCK
>   [CX] 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
>   [CX] The resulting set is the signal set pointed to by the argument set.
> SA_ONSTACK
>   [XSI] Causes signal delivery to occur on an alternate stack.
> SA_RESETHAND
>   [XSI] Causes signal dispositions to be set to SIG_DFL on entry to signal handlers.
> SA_RESTART
>   [XSI] Causes certain functions to become restartable.
> SA_SIGINFO
>   [XSI] Causes extra information to be passed to signal handlers at the time of receipt of a signal.
> SA_NOCLDWAIT
>   [XSI] Causes implementations not to create zombie processes on child death.
> SA_NODEFER
>   [XSI] Causes signal not to be automatically blocked on entry to signal handler.
> SS_ONSTACK
>   [XSI] Process is executing on an alternate signal stack.
> SS_DISABLE
>   [XSI] Alternate signal stack is disabled.
> MINSIGSTKSZ
>   [XSI] Minimum stack size for a signal handler.
> SIGSTKSZ
>   [XSI] Default size in bytes for the alternate signal stack.

> [XSI] 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.

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

>     [CX]
>     int           si_signo  Signal number.
>     int           si_code   Signal code.

>     [XSI]
>     int           si_errno  If non-zero, an errno value associated with
>                             this signal, as defined in <errno.h>.
>     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.

>     [RTS]
>     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 [XSI] signal-specific or non-signal-specific reasons why the signal was generated.

> Signal | Code | Reason
> --- | --- | ---
> [XSI] 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 | Nonexistent 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.
> [CX] Any | 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.

> [XSI] 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:

> 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:

>     [XSI]
>     void (*bsd_signal(int, void (*)(int)))(int);

>     [CX]
>     int    kill(pid_t, int);

>     [XSI]
>     int    killpg(pid_t, int);

>     [THR]
>     int    pthread_kill(pthread_t, int);
>     int    pthread_sigmask(int, const sigset_t *, sigset_t *);

>     int    raise(int);
>     [CX]
>     int    sigaction(int, const struct sigaction *restrict,
>                struct sigaction *restrict);
>     int    sigaddset(sigset_t *, int);

>     [XSI]
>     int    sigaltstack(const stack_t *restrict, stack_t *restrict);

>     [CX]
>     int    sigdelset(sigset_t *, int);
>     int    sigemptyset(sigset_t *);
>     int    sigfillset(sigset_t *);

>     [XSI]
>     int    sighold(int);
>     int    sigignore(int);
>     int    siginterrupt(int, int);

>     [CX]
>     int    sigismember(const sigset_t *, int);

>     void (*signal(int, void (*)(int)))(int);
>     [XSI]
>     int    sigpause(int);

>     [CX]
>     int    sigpending(sigset_t *);
>     int    sigprocmask(int, const sigset_t *restrict, sigset_t *restrict);

>     [RTS]
>     int    sigqueue(pid_t, int, const union sigval);

>     [XSI]
>     int    sigrelse(int);
>     void (*sigset(int, void (*)(int)))(int);

>     [CX]
>     int    sigsuspend(const sigset_t *);

>     [RTS]
>     int    sigtimedwait(const sigset_t *restrict, siginfo_t *restrict,
>                const struct timespec *restrict);

>     [CX]
>     int    sigwait(const sigset_t *restrict, int *restrict);

>     [RTS]
>     int    sigwaitinfo(const sigset_t *restrict, siginfo_t *restrict);

> [CX] 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()

#### CHANGE HISTORY

> First released in Issue 1.

#### Issue 5

> The DESCRIPTION is updated for alignment with the POSIX Realtime Extension and the POSIX Threads Extension.

> The default action for SIGURG is changed from i to iii. The function prototype for sigmask() is removed.

#### Issue 6

> The Open Group Corrigendum U035/2 is applied. In the DESCRIPTION, the wording for abnormal termination is clarified.

> The Open Group Corrigendum U028/8 is applied, correcting the prototype for the sigset() function.

> The Open Group Corrigendum U026/3 is applied, correcting the type of the sigev_notify_function function member of the sigevent structure.

> The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:

> - The SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, and SIGTTOU signals are now mandated. This is also a FIPS requirement.

> - The pid_t definition is mandated.

> The RT markings are changed to RTS to denote that the semantics are part of the Realtime Signals Extension option.

> The restrict keyword is added to the prototypes for sigaction(), sigaltstack(), sigprocmask(), sigtimedwait(), sigwait(), and sigwaitinfo().

> IEEE PASC Interpretation 1003.1 #85 is applied, adding the statement that symbols from <time.h> may be made visible when <signal.h> is included.

> Extensions beyond the ISO C standard are marked.

> IEEE Std 1003.1-2001/Cor 1-2002, item XBD/TC1/D6/14 is applied, changing the descriptive text for members of struct sigaction.

> IEEE Std 1003.1-2001/Cor 1-2002, item XBD/TC1/D6/15 is applied, correcting the definition of the sa_sigaction member of struct sigaction.

> IEEE Std 1003.1-2001/Cor 2-2004, item XBD/TC2/D6/24 is applied, reworking the ordering of the siginfo_t type structure in the DESCRIPTION. This is an editorial change and no normative change is intended.

End of informative text.

UNIX ® is a registered Trademark of The Open Group.
POSIX ® is a registered Trademark of The IEEE.
[ Main Index | XBD | XCU | XSH | XRAT ]