signal.h(3)                POSIX Programmer's Manual               signal.h(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       signal.h -- signals

SSYYNNOOPPSSIISS
       #include <signal.h>

DDEESSCCRRIIPPTTIIOONN
       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 POSIX.1-2008, _S_e_c_t_i_o_n _2_._2,
       _T_h_e _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t) to enable the visibility of these symbols
       in this header.

       The _<_s_i_g_n_a_l_._h_> header shall define the following macros, which shall
       expand to constant expressions with distinct values that have a type
       compatible with the second argument to, and the return value of, the
       _s_i_g_n_a_l() function, and whose values shall compare unequal to the
       address of any declarable function.

       SIG_DFL       Request for default signal handling.

       SIG_ERR       Return value from _s_i_g_n_a_l() in case of error.

       SIG_HOLD      Request that signal be held.

       SIG_IGN       Request that signal be ignored.

       The _<_s_i_g_n_a_l_._h_> header shall define the pptthhrreeaadd__tt, ssiizzee__tt, and uuiidd__tt
       types as described in _<_s_y_s_/_t_y_p_e_s_._h_>.

       The _<_s_i_g_n_a_l_._h_> header shall define the ttiimmeessppeecc structure as described
       in _<_t_i_m_e_._h_>.

       The _<_s_i_g_n_a_l_._h_> header shall define the following data types:

       ssiigg__aattoommiicc__tt  Possibly volatile-qualified integer type of an object
                     that can be accessed as an atomic entity, even in the
                     presence of asynchronous interrupts.

       ssiiggsseett__tt      Integer or structure type of an object used to represent
                     sets of signals.

       ppiidd__tt         As described in _<_s_y_s_/_t_y_p_e_s_._h_>.

       The _<_s_i_g_n_a_l_._h_> header shall define the pptthhrreeaadd__aattttrr__tt type as described
       in _<_s_y_s_/_t_y_p_e_s_._h_>.

       The _<_s_i_g_n_a_l_._h_> header shall define the ssiiggeevveenntt structure, which shall
       include at least the following members:

           iinntt              ssiiggeevv__nnoottiiffyy            Notification type.
           iinntt              ssiiggeevv__ssiiggnnoo             Signal number.
           uunniioonn ssiiggvvaall     ssiiggeevv__vvaalluuee             Signal value.
           vvooiidd           ((**ssiiggeevv__nnoottiiffyy__ffuunnccttiioonn))((uunniioonn ssiiggvvaall))
                                                    Notification function.
           pptthhrreeaadd__aattttrr__tt **ssiiggeevv__nnoottiiffyy__aattttrriibbuutteess  Notification attributes.

       The _<_s_i_g_n_a_l_._h_> header shall define the following symbolic constants for
       the values of _s_i_g_e_v___n_o_t_i_f_y:

       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 ssiiggvvaall union shall be defined as:

           iinntt    ssiivvaall__iinntt    Integer signal value.
           vvooiidd  **ssiivvaall__ppttrr    Pointer signal value.

       The _<_s_i_g_n_a_l_._h_> header shall declare the SIGRTMIN and SIGRTMAX macros,
       which shall expand to positive integer expressions with type iinntt, but
       which need not be constant expressions. These macros specify a range of
       signal numbers that are reserved for application use and for which the
       realtime signal behavior specified in this volume of POSIX.1-2008 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.

       The _<_s_i_g_n_a_l_._h_> header shall define the following macros that are used
       to refer to the signals that occur in the system. Signals defined here
       begin with the letters SIG followed by an uppercase letter. The macros
       shall expand to positive integer constant expressions with type iinntt and
       distinct values. The value 0 is reserved for use as the null signal
       (see _k_i_l_l()).  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):

  +----------+----------------+----------------------------------------------------+
  | SSiiggnnaall   | DDeeffaauulltt AAccttiioonn |                    DDeessccrriippttiioonn                     |
  +----------+----------------+----------------------------------------------------+
  |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,                 |
  |          |                | 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.                             |
  |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.      |
  |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.

       A     Abnormal termination of the process with additional actions.

       I     Ignore the signal.

       S     Stop the process.

       C     Continue the process, if it is stopped; otherwise, ignore the
             signal.

       The effects on the process in each case are described in the System
       Interfaces volume of POSIX.1-2008, _S_e_c_t_i_o_n _2_._4_._3, _S_i_g_n_a_l _A_c_t_i_o_n_s.

       The _<_s_i_g_n_a_l_._h_> header shall declare the ssiiggaaccttiioonn structure, which
       shall include at least the following members:

           vvooiidd   ((**ssaa__hhaannddlleerr))((iinntt))  Pointer to a signal-catching function
                                      or one of the 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 _s_a___h_a_n_d_l_e_r and _s_a___s_i_g_a_c_t_i_o_n may overlap, and a
       conforming application shall not use both simultaneously.

       The _<_s_i_g_n_a_l_._h_> header shall define the following macros which shall
       expand to integer constant expressions that need not be usable in ##iiff
       preprocessing directives:

       SIG_BLOCK     The resulting set is the union of the current set and the
                     signal set pointed to by the argument _s_e_t.

       SIG_UNBLOCK   The resulting set is the intersection of the current set
                     and the complement of the signal set pointed to by the
                     argument _s_e_t.

       SIG_SETMASK   The resulting set is the signal set pointed to by the
                     argument _s_e_t.

       The _<_s_i_g_n_a_l_._h_> header shall also define the following symbolic
       constants:

       SA_NOCLDSTOP  Do not generate SIGCHLD when children stop
                     or stopped children continue.

       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 _<_s_i_g_n_a_l_._h_> header shall define the mmccoonntteexxtt__tt type through ttyyppeeddeeff.

       The _<_s_i_g_n_a_l_._h_> header shall define the uuccoonntteexxtt__tt type as a structure
       that shall include at least the following members:

           uuccoonntteexxtt__tt **uucc__lliinnkk     Pointer to the context that is resumed
                                   when this context returns.
           sigset_t    uc_sigmask  The set of signals that are blocked when this
                                   context is active.
           stack_t     uc_stack    The stack used by this context.
           mcontext_t  uc_mcontext A machine-specific representation of the saved
                                   context.

       The _<_s_i_g_n_a_l_._h_> header shall define the ssttaacckk__tt type as a structure,
       which shall include at least the following members:

           vvooiidd     **ssss__sspp       Stack base or pointer.
           size_t    ss_size     Stack size.
           int       ss_flags    Flags.

       The _<_s_i_g_n_a_l_._h_> header shall define the ssiiggiinnffoo__tt type as a structure,
       which shall include at least the following members:

           iinntt           ssii__ssiiggnnoo  Signal number.
           int           si_code   Signal code.
           int           si_errno  If non-zero, an _e_r_r_n_o value associated with
                                   this signal, as described in <<eerrrrnnoo..hh>>.
           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 _<_s_i_g_n_a_l_._h_> header shall define the symbolic constants in the CCooddee
       column of the following table for use as values of _s_i___c_o_d_e that are
       signal-specific or non-signal-specific reasons why the signal was
       generated.

+-------+-------------+------------------------------------------------------------------+
|SSiiggnnaall |    CCooddee     |                             RReeaassoonn                               |
+-------+-------------+------------------------------------------------------------------+
|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 ccoorree file.   |
|       |CLD_DUMPED   |Child has terminated abnormally and created a ccoorree 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.                                              |
+-------+-------------+------------------------------------------------------------------+
|Any    |SI_USER      |Signal sent by _k_i_l_l().                                            |
|       |SI_QUEUE     |Signal sent by _s_i_g_q_u_e_u_e().                                        |
|       |SI_TIMER     |Signal generated by expiration of a timer set by _t_i_m_e_r___s_e_t_t_i_m_e(). |
|       |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 _s_i___c_o_d_e 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:

    +--------+----------------+---------------------------------------------------+
    |SSiiggnnaall  |     MMeemmbbeerr     |                       VVaalluuee                       |
    +--------+----------------+---------------------------------------------------+
    |SIGILL  | vvooiidd ** _s_i___a_d_d_r | Address of faulting instruction.                  |
    |SIGFPE  |                |                                                   |
    +--------+----------------+---------------------------------------------------+
    |SIGSEGV | vvooiidd ** _s_i___a_d_d_r | Address of faulting memory reference.             |
    |SIGBUS  |                |                                                   |
    +--------+----------------+---------------------------------------------------+
    |SIGCHLD | ppiidd__tt _s_i___p_i_d   | Child process ID.                                 |
    |        | iinntt _s_i___s_t_a_t_u_s  | Exit value or signal.                             |
    |        | uuiidd__tt _s_i___u_i_d   | Real user ID of the process that sent the signal. |
    +--------+----------------+---------------------------------------------------+
    |SIGPOLL | lloonngg _s_i___b_a_n_d   | Band event for POLL_IN, POLL_OUT, or POLL_MSG.    |
    +--------+----------------+---------------------------------------------------+
       For some implementations, the value of _s_i___a_d_d_r may be inaccurate.

       The following shall be declared as functions and may also be defined as
       macros. Function prototypes shall be provided.

           iinntt    kkiillll((ppiidd__tt,, iinntt));;
           iinntt    kkiillllppgg((ppiidd__tt,, iinntt));;
           vvooiidd   ppssiiggiinnffoo((ccoonnsstt ssiiggiinnffoo__tt **,, ccoonnsstt cchhaarr **));;
           vvooiidd   ppssiiggnnaall((iinntt,, ccoonnsstt cchhaarr **));;
           iinntt    pptthhrreeaadd__kkiillll((pptthhrreeaadd__tt,, iinntt));;
           iinntt    pptthhrreeaadd__ssiiggmmaasskk((iinntt,, ccoonnsstt ssiiggsseett__tt **rreessttrriicctt,,
                      ssiiggsseett__tt **rreessttrriicctt));;
           iinntt    rraaiissee((iinntt));;
           iinntt    ssiiggaaccttiioonn((iinntt,, ccoonnsstt ssttrruucctt ssiiggaaccttiioonn **rreessttrriicctt,,
                      ssttrruucctt ssiiggaaccttiioonn **rreessttrriicctt));;
           iinntt    ssiiggaaddddsseett((ssiiggsseett__tt **,, iinntt));;
           iinntt    ssiiggaallttssttaacckk((ccoonnsstt ssttaacckk__tt **rreessttrriicctt,, ssttaacckk__tt **rreessttrriicctt));;
           iinntt    ssiiggddeellsseett((ssiiggsseett__tt **,, iinntt));;
           iinntt    ssiiggeemmppttyysseett((ssiiggsseett__tt **));;
           iinntt    ssiiggffiillllsseett((ssiiggsseett__tt **));;
           iinntt    ssiigghhoolldd((iinntt));;
           iinntt    ssiiggiiggnnoorree((iinntt));;
           iinntt    ssiiggiinntteerrrruupptt((iinntt,, iinntt));;
           iinntt    ssiiggiissmmeemmbbeerr((ccoonnsstt ssiiggsseett__tt **,, iinntt));;
           vvooiidd ((**ssiiggnnaall((iinntt,, vvooiidd ((**))((iinntt))))))((iinntt));;
           iinntt    ssiiggppaauussee((iinntt));;
           iinntt    ssiiggppeennddiinngg((ssiiggsseett__tt **));;
           iinntt    ssiiggpprrooccmmaasskk((iinntt,, ccoonnsstt ssiiggsseett__tt **rreessttrriicctt,, ssiiggsseett__tt **rreessttrriicctt));;
           iinntt    ssiiggqquueeuuee((ppiidd__tt,, iinntt,, ccoonnsstt uunniioonn ssiiggvvaall));;
           iinntt    ssiiggrreellssee((iinntt));;
           vvooiidd ((**ssiiggsseett((iinntt,, vvooiidd ((**))((iinntt))))))((iinntt));;
           iinntt    ssiiggssuussppeenndd((ccoonnsstt ssiiggsseett__tt **));;
           iinntt    ssiiggttiimmeeddwwaaiitt((ccoonnsstt ssiiggsseett__tt **rreessttrriicctt,, ssiiggiinnffoo__tt **rreessttrriicctt,,
                      ccoonnsstt ssttrruucctt ttiimmeessppeecc **rreessttrriicctt));;
           iinntt    ssiiggwwaaiitt((ccoonnsstt ssiiggsseett__tt **rreessttrriicctt,, iinntt **rreessttrriicctt));;
           iinntt    ssiiggwwaaiittiinnffoo((ccoonnsstt ssiiggsseett__tt **rreessttrriicctt,, ssiiggiinnffoo__tt **rreessttrriicctt));;

       Inclusion of the _<_s_i_g_n_a_l_._h_> header may make visible all symbols from
       the _<_t_i_m_e_._h_> header.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       On systems not supporting the XSI option, the _s_i___p_i_d and _s_i___u_i_d members
       of ssiiggiinnffoo__tt are only required to be valid when _s_i___c_o_d_e is SI_USER or
       SI_QUEUE. On XSI-conforming systems, they are also valid for all
       _s_i___c_o_d_e values less than or equal to 0; however, it is unspecified
       whether SI_USER and SI_QUEUE have values less than or equal to zero,
       and therefore XSI applications should check whether _s_i___c_o_d_e has the
       value SI_USER or SI_QUEUE or is less than or equal to 0 to tell whether
       _s_i___p_i_d and _s_i___u_i_d are valid.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       The SIGPOLL and SIGPROF signals may be removed in a future version.

SSEEEE AALLSSOO
       <<eerrrrnnoo..hh>>, <<ssttrrooppttss..hh>>, <<ssyyss__ttyyppeess..hh>>, <<ttiimmee..hh>>

       The System Interfaces volume of POSIX.1-2008, _S_e_c_t_i_o_n _2_._2, _T_h_e
       _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t, _a_l_a_r_m(), _i_o_c_t_l(), _k_i_l_l(), _k_i_l_l_p_g(),
       _p_s_i_g_i_n_f_o(), _p_t_h_r_e_a_d___k_i_l_l(), _p_t_h_r_e_a_d___s_i_g_m_a_s_k(), _r_a_i_s_e(), _s_i_g_a_c_t_i_o_n(),
       _s_i_g_a_d_d_s_e_t(), _s_i_g_a_l_t_s_t_a_c_k(), _s_i_g_d_e_l_s_e_t(), _s_i_g_e_m_p_t_y_s_e_t(), _s_i_g_f_i_l_l_s_e_t(),
       _s_i_g_h_o_l_d(), _s_i_g_i_n_t_e_r_r_u_p_t(), _s_i_g_i_s_m_e_m_b_e_r(), _s_i_g_n_a_l(), _s_i_g_p_e_n_d_i_n_g(),
       _s_i_g_q_u_e_u_e(), _s_i_g_s_u_s_p_e_n_d(), _s_i_g_t_i_m_e_d_w_a_i_t(), _s_i_g_w_a_i_t(), _t_i_m_e_r___c_r_e_a_t_e(),
       _w_a_i_t(), _w_a_i_t_i_d()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                          signal.h(3)
