1signal.h(0P)               POSIX Programmer's Manual              signal.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       signal.h — signals
14

SYNOPSIS

16       #include <signal.h>
17

DESCRIPTION

19       Some of the functionality described on this reference page extends  the
20       ISO C  standard. Applications shall define the appropriate feature test
21       macro (see the System Interfaces volume of POSIX.1‐2008,  Section  2.2,
22       The  Compilation Environment) to enable the visibility of these symbols
23       in this header.
24
25       The <signal.h> header shall define the following  macros,  which  shall
26       expand  to  constant  expressions with distinct values that have a type
27       compatible with the second argument to, and the return  value  of,  the
28       signal()  function,  and  whose  values  shall  compare  unequal to the
29       address of any declarable function.
30
31       SIG_DFL       Request for default signal handling.
32
33       SIG_ERR       Return value from signal() in case of error.
34
35       SIG_HOLD      Request that signal be held.
36
37       SIG_IGN       Request that signal be ignored.
38
39       The <signal.h> header shall define the  pthread_t,  size_t,  and  uid_t
40       types as described in <sys/types.h>.
41
42       The  <signal.h> header shall define the timespec structure as described
43       in <time.h>.
44
45       The <signal.h> header shall define the following data types:
46
47       sig_atomic_t  Possibly volatile-qualified integer  type  of  an  object
48                     that  can  be  accessed  as an atomic entity, even in the
49                     presence of asynchronous interrupts.
50
51       sigset_t      Integer or structure type of an object used to  represent
52                     sets of signals.
53
54       pid_t         As described in <sys/types.h>.
55
56       The <signal.h> header shall define the pthread_attr_t type as described
57       in <sys/types.h>.
58
59       The <signal.h> header shall define the sigevent structure, which  shall
60       include at least the following members:
61
62           int              sigev_notify            Notification type.
63           int              sigev_signo             Signal number.
64           union sigval     sigev_value             Signal value.
65           void           (*sigev_notify_function)(union sigval)
66                                                    Notification function.
67           pthread_attr_t *sigev_notify_attributes  Notification attributes.
68
69       The <signal.h> header shall define the following symbolic constants for
70       the values of sigev_notify:
71
72       SIGEV_NONE    No asynchronous notification is delivered when the  event
73                     of interest occurs.
74
75       SIGEV_SIGNAL  A  queued  signal,  with an application-defined value, is
76                     generated when the event of interest occurs.
77
78       SIGEV_THREAD  A notification function is called  to  perform  notifica‐
79                     tion.
80
81       The sigval union shall be defined as:
82
83           int    sival_int    Integer signal value.
84           void  *sival_ptr    Pointer signal value.
85
86       The  <signal.h>  header shall declare the SIGRTMIN and SIGRTMAX macros,
87       which shall expand to positive integer expressions with type  int,  but
88       which need not be constant expressions. These macros specify a range of
89       signal numbers that are reserved for application use and for which  the
90       realtime  signal  behavior  specified in this volume of POSIX.1‐2008 is
91       supported. The signal numbers in this range do not overlap any  of  the
92       signals specified in the following table.
93
94       The  range  SIGRTMIN  through SIGRTMAX inclusive shall include at least
95       {RTSIG_MAX} signal numbers.
96
97       It is implementation-defined whether realtime signal behavior  is  sup‐
98       ported for other signals.
99
100       The  <signal.h>  header shall define the following macros that are used
101       to refer to the signals that occur in the system. Signals defined  here
102       begin  with the letters SIG followed by an uppercase letter. The macros
103       shall expand to positive integer constant expressions with type int and
104       distinct  values.  The  value  0 is reserved for use as the null signal
105       (see kill()).  Additional implementation-defined signals may  occur  in
106       the system.
107
108       The ISO C standard only requires the signal names SIGABRT, SIGFPE, SIG‐
109       ILL, SIGINT, SIGSEGV, and SIGTERM to be defined.
110
111       The  following  signals  shall  be  supported  on  all  implementations
112       (default actions are explained below the table):
113
114  ┌──────────┬────────────────┬────────────────────────────────────────────────────┐
115Signal   Default Action Description                     
116  ├──────────┼────────────────┼────────────────────────────────────────────────────┤
117  │SIGABRT   │       A        │ Process abort signal.                              │
118  │SIGALRM   │       T        │ Alarm clock.                                       │
119  │SIGBUS    │       A        │ Access to an undefined portion of a memory object. │
120  │SIGCHLD   │       I        │ Child process terminated, stopped,                 │
121  │          │                │ or continued.                                      │
122  │SIGCONT   │       C        │ Continue executing, if stopped.                    │
123  │SIGFPE    │       A        │ Erroneous arithmetic operation.                    │
124  │SIGHUP    │       T        │ Hangup.                                            │
125  │SIGILL    │       A        │ Illegal instruction.                               │
126  │SIGINT    │       T        │ Terminal interrupt signal.                         │
127  │SIGKILL   │       T        │ Kill (cannot be caught or ignored).                │
128  │SIGPIPE   │       T        │ Write on a pipe with no one to read it.            │
129  │SIGQUIT   │       A        │ Terminal quit signal.                              │
130  │SIGSEGV   │       A        │ Invalid memory reference.                          │
131  │SIGSTOP   │       S        │ Stop executing (cannot be caught or ignored).      │
132  │SIGTERM   │       T        │ Termination signal.                                │
133  │SIGTSTP   │       S        │ Terminal stop signal.                              │
134  │SIGTTIN   │       S        │ Background process attempting read.                │
135  │SIGTTOU   │       S        │ Background process attempting write.               │
136  │SIGUSR1   │       T        │ User-defined signal 1.                             │
137  │SIGUSR2   │       T        │ User-defined signal 2.                             │
138  │SIGPOLL   │       T        │ Pollable event.                                    │
139  │SIGPROF   │       T        │ Profiling timer expired.                           │
140  │SIGSYS    │       A        │ Bad system call.                                   │
141  │SIGTRAP   │       A        │ Trace/breakpoint trap.                             │
142  │SIGURG    │       I        │ High bandwidth data is available at a socket.      │
143  │SIGVTALRM │       T        │ Virtual timer expired.                             │
144  │SIGXCPU   │       A        │ CPU time limit exceeded.                           │
145  │SIGXFSZ   │       A        │ File size limit exceeded.                          │
146  │          │                │                                                    │
147  └──────────┴────────────────┴────────────────────────────────────────────────────┘
148       The default actions are as follows:
149
150       T     Abnormal termination of the process.
151
152       A     Abnormal termination of the process with additional actions.
153
154       I     Ignore the signal.
155
156       S     Stop the process.
157
158       C     Continue  the  process,  if  it is stopped; otherwise, ignore the
159             signal.
160
161       The effects on the process in each case are  described  in  the  System
162       Interfaces volume of POSIX.1‐2008, Section 2.4.3, Signal Actions.
163
164       The  <signal.h>  header  shall  declare  the sigaction structure, which
165       shall include at least the following members:
166
167           void   (*sa_handler)(int)  Pointer to a signal-catching function
168                                      or one of the SIG_IGN or SIG_DFL.
169           sigset_t sa_mask           Set of signals to be blocked during execution
170                                      of the signal handling function.
171           int      sa_flags          Special flags.
172           void   (*sa_sigaction)(int, siginfo_t *, void *)
173                                      Pointer to a signal-catching function.
174
175       The storage occupied by sa_handler and sa_sigaction may overlap, and  a
176       conforming application shall not use both simultaneously.
177
178       The  <signal.h>  header  shall  define the following macros which shall
179       expand to integer constant expressions that need not be usable  in  #if
180       preprocessing directives:
181
182       SIG_BLOCK     The resulting set is the union of the current set and the
183                     signal set pointed to by the argument set.
184
185       SIG_UNBLOCK   The resulting set is the intersection of the current  set
186                     and  the  complement  of the signal set pointed to by the
187                     argument set.
188
189       SIG_SETMASK   The resulting set is the signal set  pointed  to  by  the
190                     argument set.
191
192       The  <signal.h>  header  shall  also define the following symbolic con‐
193       stants:
194
195       SA_NOCLDSTOP  Do not generate SIGCHLD when children stop
196                     or stopped children continue.
197
198       SA_ONSTACK    Causes signal delivery to occur on an alternate stack.
199
200       SA_RESETHAND  Causes signal dispositions to be set to SIG_DFL on  entry
201                     to signal handlers.
202
203       SA_RESTART    Causes certain functions to become restartable.
204
205       SA_SIGINFO    Causes  extra information to be passed to signal handlers
206                     at the time of receipt of a signal.
207
208       SA_NOCLDWAIT  Causes implementations not to create zombie processes  on
209                     child death.
210
211       SA_NODEFER    Causes signal not to be automatically blocked on entry to
212                     signal handler.
213
214       SS_ONSTACK    Process is executing on an alternate signal stack.
215
216       SS_DISABLE    Alternate signal stack is disabled.
217
218       MINSIGSTKSZ   Minimum stack size for a signal handler.
219
220       SIGSTKSZ      Default size in bytes for the alternate signal stack.
221
222       The <signal.h> header shall define the mcontext_t type through typedef.
223
224       The <signal.h> header shall define the ucontext_t type as  a  structure
225       that shall include at least the following members:
226
227           ucontext_t *uc_link     Pointer to the context that is resumed
228                                   when this context returns.
229           sigset_t    uc_sigmask  The set of signals that are blocked when this
230                                   context is active.
231           stack_t     uc_stack    The stack used by this context.
232           mcontext_t  uc_mcontext A machine-specific representation of the saved
233                                   context.
234
235       The  <signal.h>  header  shall  define the stack_t type as a structure,
236       which shall include at least the following members:
237
238           void     *ss_sp       Stack base or pointer.
239           size_t    ss_size     Stack size.
240           int       ss_flags    Flags.
241
242       The <signal.h> header shall define the siginfo_t type as  a  structure,
243       which shall include at least the following members:
244
245           int           si_signo  Signal number.
246           int           si_code   Signal code.
247           int           si_errno  If non-zero, an errno value associated with
248                                   this signal, as described in <errno.h>.
249           pid_t         si_pid    Sending process ID.
250           uid_t         si_uid    Real user ID of sending process.
251           void         *si_addr   Address of faulting instruction.
252           int           si_status Exit value or signal.
253           long          si_band   Band event for SIGPOLL.
254           union sigval  si_value  Signal value.
255
256       The  <signal.h>  header shall define the symbolic constants in the Code
257       column of the following table for use as values  of  si_code  that  are
258       signal-specific  or non-signal-specific reasons why the signal was gen‐
259       erated.
260
261┌───────┬─────────────┬──────────────────────────────────────────────────────────────────┐
262Signal Code     Reason                               
263├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
264│SIGILL │ILL_ILLOPC   │Illegal opcode.                                                   │
265│       │ILL_ILLOPN   │Illegal operand.                                                  │
266│       │ILL_ILLADR   │Illegal addressing mode.                                          │
267│       │ILL_ILLTRP   │Illegal trap.                                                     │
268│       │ILL_PRVOPC   │Privileged opcode.                                                │
269│       │ILL_PRVREG   │Privileged register.                                              │
270│       │ILL_COPROC   │Coprocessor error.                                                │
271│       │ILL_BADSTK   │Internal stack error.                                             │
272├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
273│SIGFPE │FPE_INTDIV   │Integer divide by zero.                                           │
274│       │FPE_INTOVF   │Integer overflow.                                                 │
275│       │FPE_FLTDIV   │Floating-point divide by zero.                                    │
276│       │FPE_FLTOVF   │Floating-point overflow.                                          │
277│       │FPE_FLTUND   │Floating-point underflow.                                         │
278│       │FPE_FLTRES   │Floating-point inexact result.                                    │
279│       │FPE_FLTINV   │Invalid floating-point operation.                                 │
280│       │FPE_FLTSUB   │Subscript out of range.                                           │
281├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
282│SIGSEGV│SEGV_MAPERR  │Address not mapped to object.                                     │
283│       │SEGV_ACCERR  │Invalid permissions for mapped object.                            │
284├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
285│SIGBUS │BUS_ADRALN   │Invalid address alignment.                                        │
286│       │BUS_ADRERR   │Nonexistent physical address.                                     │
287│       │BUS_OBJERR   │Object-specific hardware error.                                   │
288├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
289│SIGTRAP│TRAP_BRKPT   │Process breakpoint.                                               │
290│       │TRAP_TRACE   │Process trace trap.                                               │
291├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
292│SIGCHLD│CLD_EXITED   │Child has exited.                                                 │
293│       │CLD_KILLED   │Child has terminated abnormally and did not create a core file.   │
294│       │CLD_DUMPED   │Child has terminated abnormally and created a core file.          │
295│       │CLD_TRAPPED  │Traced child has trapped.                                         │
296│       │CLD_STOPPED  │Child has stopped.                                                │
297│       │CLD_CONTINUED│Stopped child has continued.                                      │
298├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
299│SIGPOLL│POLL_IN      │Data input available.                                             │
300│       │POLL_OUT     │Output buffers available.                                         │
301│       │POLL_MSG     │Input message available.                                          │
302│       │POLL_ERR     │I/O error.                                                        │
303│       │POLL_PRI     │High priority input available.                                    │
304│       │POLL_HUP     │Device disconnected.                                              │
305├───────┼─────────────┼──────────────────────────────────────────────────────────────────┤
306│Any    │SI_USER      │Signal sent by kill().                                            │
307│       │SI_QUEUE     │Signal sent by sigqueue().                                        │
308│       │SI_TIMER     │Signal generated by expiration of a timer set by timer_settime(). │
309│       │SI_ASYNCIO   │Signal generated by completion of an asynchronous I/O             │
310│       │             │request.                                                          │
311│       │SI_MESGQ     │Signal generated by arrival of a message on an empty message      │
312│       │             │queue.                                                            │
313└───────┴─────────────┴──────────────────────────────────────────────────────────────────┘
314       Implementations may support additional si_code values not  included  in
315       this  list,  may  generate  values  included in this list under circum‐
316       stances other than those described in this list, and may contain exten‐
317       sions  or  limitations  that  prevent some values from being generated.
318       Implementations do  not  generate  a  different  value  from  the  ones
319       described in this list for circumstances described in this list.
320
321       In  addition, the following signal-specific information shall be avail‐
322       able:
323
324    ┌────────┬────────────────┬───────────────────────────────────────────────────┐
325Signal  Member     Value                       
326    ├────────┼────────────────┼───────────────────────────────────────────────────┤
327    │SIGILL  │ void * si_addr │ Address of faulting instruction.                  │
328    │SIGFPE  │                │                                                   │
329    ├────────┼────────────────┼───────────────────────────────────────────────────┤
330    │SIGSEGV │ void * si_addr │ Address of faulting memory reference.             │
331    │SIGBUS  │                │                                                   │
332    ├────────┼────────────────┼───────────────────────────────────────────────────┤
333    │SIGCHLD │ pid_t si_pid   │ Child process ID.                                 │
334    │        │ int si_status  │ Exit value or signal.                             │
335    │        │ uid_t si_uid   │ Real user ID of the process that sent the signal. │
336    ├────────┼────────────────┼───────────────────────────────────────────────────┤
337    │SIGPOLL │ long si_band   │ Band event for POLL_IN, POLL_OUT, or POLL_MSG.    │
338    └────────┴────────────────┴───────────────────────────────────────────────────┘
339       For some implementations, the value of si_addr may be inaccurate.
340
341       The following shall be declared as functions and may also be defined as
342       macros. Function prototypes shall be provided.
343
344           int    kill(pid_t, int);
345           int    killpg(pid_t, int);
346           void   psiginfo(const siginfo_t *, const char *);
347           void   psignal(int, const char *);
348           int    pthread_kill(pthread_t, int);
349           int    pthread_sigmask(int, const sigset_t *restrict,
350                      sigset_t *restrict);
351           int    raise(int);
352           int    sigaction(int, const struct sigaction *restrict,
353                      struct sigaction *restrict);
354           int    sigaddset(sigset_t *, int);
355           int    sigaltstack(const stack_t *restrict, stack_t *restrict);
356           int    sigdelset(sigset_t *, int);
357           int    sigemptyset(sigset_t *);
358           int    sigfillset(sigset_t *);
359           int    sighold(int);
360           int    sigignore(int);
361           int    siginterrupt(int, int);
362           int    sigismember(const sigset_t *, int);
363           void (*signal(int, void (*)(int)))(int);
364           int    sigpause(int);
365           int    sigpending(sigset_t *);
366           int    sigprocmask(int, const sigset_t *restrict, sigset_t *restrict);
367           int    sigqueue(pid_t, int, const union sigval);
368           int    sigrelse(int);
369           void (*sigset(int, void (*)(int)))(int);
370           int    sigsuspend(const sigset_t *);
371           int    sigtimedwait(const sigset_t *restrict, siginfo_t *restrict,
372                      const struct timespec *restrict);
373           int    sigwait(const sigset_t *restrict, int *restrict);
374           int    sigwaitinfo(const sigset_t *restrict, siginfo_t *restrict);
375
376       Inclusion  of  the  <signal.h> header may make visible all symbols from
377       the <time.h> header.
378
379       The following sections are informative.
380

APPLICATION USAGE

382       On systems not supporting the XSI option, the si_pid and si_uid members
383       of  siginfo_t  are only required to be valid when si_code is SI_USER or
384       SI_QUEUE. On XSI-conforming  systems,  they  are  also  valid  for  all
385       si_code  values  less  than  or  equal to 0; however, it is unspecified
386       whether SI_USER and SI_QUEUE have values less than or  equal  to  zero,
387       and  therefore  XSI  applications  should check whether si_code has the
388       value SI_USER or SI_QUEUE or is less than or equal to 0 to tell whether
389       si_pid and si_uid are valid.
390

RATIONALE

392       None.
393

FUTURE DIRECTIONS

395       The SIGPOLL and SIGPROF signals may be removed in a future version.
396

SEE ALSO

398       <errno.h>, <stropts.h>, <sys_types.h>, <time.h>
399
400       The System Interfaces volume of POSIX.1‐2008, Section 2.2, The Compila‐
401       tion Environment, alarm(), ioctl(), kill(), killpg(), psiginfo(),
402       pthread_kill(), pthread_sigmask(), raise(), sigaction(), sigaddset(),
403       sigaltstack(), sigdelset(), sigemptyset(), sigfillset(), sighold(),
404       siginterrupt(), sigismember(), signal(), sigpending(), sigqueue(), sig‐
405       suspend(), sigtimedwait(), sigwait(), timer_create(), wait(), waitid()
406
408       Portions of this text are reprinted and reproduced in  electronic  form
409       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
410       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
411       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
412       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
413       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
414       event of any discrepancy between this version and the original IEEE and
415       The  Open Group Standard, the original IEEE and The Open Group Standard
416       is the referee document. The original Standard can be  obtained  online
417       at http://www.unix.org/online.html .
418
419       Any  typographical  or  formatting  errors that appear in this page are
420       most likely to have been introduced during the conversion of the source
421       files  to  man page format. To report such errors, see https://www.ker
422       nel.org/doc/man-pages/reporting_bugs.html .
423
424
425
426IEEE/The Open Group                  2013                         signal.h(0P)
Impressum