1SIGNAL(7)                  Linux Programmer's Manual                 SIGNAL(7)
2
3
4

NAME

6       signal - overview of signals
7

DESCRIPTION

9       Linux  supports both POSIX reliable signals (hereinafter "standard sig‐
10       nals") and POSIX real-time signals.
11
12   Signal dispositions
13       Each signal has a current disposition, which determines how the process
14       behaves when it is delivered the signal.
15
16       The  entries  in  the  "Action"  column  of the table below specify the
17       default disposition for each signal, as follows:
18
19       Term   Default action is to terminate the process.
20
21       Ign    Default action is to ignore the signal.
22
23       Core   Default action is to terminate the process and  dump  core  (see
24              core(5)).
25
26       Stop   Default action is to stop the process.
27
28       Cont   Default  action  is  to  continue the process if it is currently
29              stopped.
30
31       A process can change the disposition of a signal using sigaction(2)  or
32       signal(2).   (The  latter  is  less portable when establishing a signal
33       handler; see signal(2) for  details.)   Using  these  system  calls,  a
34       process  can  elect one of the following behaviors to occur on delivery
35       of the signal: perform the default action; ignore the signal; or  catch
36       the signal with a signal handler, a programmer-defined function that is
37       automatically invoked when the signal is delivered.
38
39       By default, a signal handler is invoked on the  normal  process  stack.
40       It  is  possible  to  arrange that the signal handler uses an alternate
41       stack; see sigaltstack(2) for a discussion of how to do this  and  when
42       it might be useful.
43
44       The  signal  disposition is a per-process attribute: in a multithreaded
45       application, the disposition of a particular signal is the same for all
46       threads.
47
48       A child created via fork(2) inherits a copy of its parent's signal dis‐
49       positions.  During an execve(2), the dispositions  of  handled  signals
50       are  reset to the default; the dispositions of ignored signals are left
51       unchanged.
52
53   Sending a signal
54       The following system calls and library functions allow  the  caller  to
55       send a signal:
56
57       raise(3)        Sends a signal to the calling thread.
58
59       kill(2)         Sends  a  signal to a specified process, to all members
60                       of a specified process group, or to  all  processes  on
61                       the system.
62
63       killpg(3)       Sends  a  signal  to  all of the members of a specified
64                       process group.
65
66       pthread_kill(3) Sends a signal to a specified POSIX thread in the  same
67                       process as the caller.
68
69       tgkill(2)       Sends  a signal to a specified thread within a specific
70                       process.  (This is the system call  used  to  implement
71                       pthread_kill(3).)
72
73       sigqueue(3)     Sends  a  real-time  signal with accompanying data to a
74                       specified process.
75
76   Waiting for a signal to be caught
77       The following system calls suspend  execution  of  the  calling  thread
78       until  a  signal  is  caught  (or  an  unhandled  signal terminates the
79       process):
80
81       pause(2)        Suspends execution until any signal is caught.
82
83       sigsuspend(2)   Temporarily changes the signal  mask  (see  below)  and
84                       suspends execution until one of the unmasked signals is
85                       caught.
86
87   Synchronously accepting a signal
88       Rather than asynchronously catching a signal via a signal  handler,  it
89       is  possible to synchronously accept the signal, that is, to block exe‐
90       cution until the signal is delivered, at which point the kernel returns
91       information about the signal to the caller.  There are two general ways
92       to do this:
93
94       * sigwaitinfo(2), sigtimedwait(2),  and  sigwait(3)  suspend  execution
95         until  one  of  the signals in a specified set is delivered.  Each of
96         these calls returns information about the delivered signal.
97
98       * signalfd(2) returns a file descriptor that can be used to read infor‐
99         mation  about signals that are delivered to the caller.  Each read(2)
100         from this file descriptor blocks until one of the signals in the  set
101         specified  in  the  signalfd(2) call is delivered to the caller.  The
102         buffer returned by read(2) contains a structure describing  the  sig‐
103         nal.
104
105   Signal mask and pending signals
106       A  signal  may  be  blocked,  which means that it will not be delivered
107       until it is later unblocked.  Between the time when it is generated and
108       when it is delivered a signal is said to be pending.
109
110       Each  thread  in  a process has an independent signal mask, which indi‐
111       cates the set of signals that the  thread  is  currently  blocking.   A
112       thread  can  manipulate its signal mask using pthread_sigmask(3).  In a
113       traditional single-threaded application, sigprocmask(2) can be used  to
114       manipulate the signal mask.
115
116       A  child  created  via  fork(2)  inherits a copy of its parent's signal
117       mask; the signal mask is preserved across execve(2).
118
119       A signal may be generated (and thus pending) for a process as  a  whole
120       (e.g., when sent using kill(2)) or for a specific thread (e.g., certain
121       signals, such as SIGSEGV and SIGFPE, generated as a consequence of exe‐
122       cuting  a specific machine-language instruction are thread directed, as
123       are signals targeted at a specific thread  using  pthread_kill(3)).   A
124       process-directed signal may be delivered to any one of the threads that
125       does not currently have the signal blocked.  If more than  one  of  the
126       threads  has the signal unblocked, then the kernel chooses an arbitrary
127       thread to which to deliver the signal.
128
129       A thread can obtain the set of signals that it  currently  has  pending
130       using  sigpending(2).  This set will consist of the union of the set of
131       pending process-directed signals and the set of signals pending for the
132       calling thread.
133
134       A  child created via fork(2) initially has an empty pending signal set;
135       the pending signal set is preserved across an execve(2).
136
137   Standard signals
138       Linux supports the standard signals listed below.  The second column of
139       the  table  indicates  which  standard  (if  any) specified the signal:
140       "P1990"  indicates  that  the  signal  is  described  in  the  original
141       POSIX.1-1990  standard;  "P2001" indicates that the signal was added in
142       SUSv2 and POSIX.1-2001.
143
144       Signal      Standard   Action   Comment
145       ────────────────────────────────────────────────────────────────────────
146       SIGABRT      P1990      Core    Abort signal from abort(3)
147       SIGALRM      P1990      Term    Timer signal from alarm(2)
148       SIGBUS       P2001      Core    Bus error (bad memory access)
149       SIGCHLD      P1990      Ign     Child stopped or terminated
150       SIGCLD         -        Ign     A synonym for SIGCHLD
151       SIGCONT      P1990      Cont    Continue if stopped
152       SIGEMT         -        Term    Emulator trap
153       SIGFPE       P1990      Core    Floating-point exception
154       SIGHUP       P1990      Term    Hangup detected on controlling terminal
155                                       or death of controlling process
156       SIGILL       P1990      Core    Illegal Instruction
157       SIGINFO        -                A synonym for SIGPWR
158       SIGINT       P1990      Term    Interrupt from keyboard
159       SIGIO          -        Term    I/O now possible (4.2BSD)
160       SIGIOT         -        Core    IOT trap. A synonym for SIGABRT
161       SIGKILL      P1990      Term    Kill signal
162       SIGLOST        -        Term    File lock lost (unused)
163       SIGPIPE      P1990      Term    Broken pipe: write to pipe with no
164                                       readers; see pipe(7)
165       SIGPOLL      P2001      Term    Pollable event (Sys V).
166                                       Synonym for SIGIO
167       SIGPROF      P2001      Term    Profiling timer expired
168       SIGPWR         -        Term    Power failure (System V)
169       SIGQUIT      P1990      Core    Quit from keyboard
170       SIGSEGV      P1990      Core    Invalid memory reference
171       SIGSTKFLT      -        Term    Stack fault on coprocessor (unused)
172       SIGSTOP      P1990      Stop    Stop process
173       SIGTSTP      P1990      Stop    Stop typed at terminal
174       SIGSYS       P2001      Core    Bad system call (SVr4);
175                                       see also seccomp(2)
176       SIGTERM      P1990      Term    Termination signal
177       SIGTRAP      P2001      Core    Trace/breakpoint trap
178       SIGTTIN      P1990      Stop    Terminal input for background process
179       SIGTTOU      P1990      Stop    Terminal output for background process
180       SIGUNUSED      -        Core    Synonymous with SIGSYS
181       SIGURG       P2001      Ign     Urgent condition on socket (4.2BSD)
182       SIGUSR1      P1990      Term    User-defined signal 1
183       SIGUSR2      P1990      Term    User-defined signal 2
184       SIGVTALRM    P2001      Term    Virtual alarm clock (4.2BSD)
185       SIGXCPU      P2001      Core    CPU time limit exceeded (4.2BSD);
186                                       see setrlimit(2)
187       SIGXFSZ      P2001      Core    File size limit exceeded (4.2BSD);
188                                       see setrlimit(2)
189       SIGWINCH       -        Ign     Window resize signal (4.3BSD, Sun)
190
191       The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
192
193       Up to and including Linux 2.2, the default behavior for  SIGSYS,  SIGX‐
194       CPU,  SIGXFSZ,  and (on architectures other than SPARC and MIPS) SIGBUS
195       was to terminate the process (without a core  dump).   (On  some  other
196       UNIX systems the default action for SIGXCPU and SIGXFSZ is to terminate
197       the  process  without  a  core  dump.)   Linux  2.4  conforms  to   the
198       POSIX.1-2001  requirements  for  these signals, terminating the process
199       with a core dump.
200
201       SIGEMT is not specified in POSIX.1-2001, but  nevertheless  appears  on
202       most  other UNIX systems, where its default action is typically to ter‐
203       minate the process with a core dump.
204
205       SIGPWR (which is not specified in POSIX.1-2001) is typically ignored by
206       default on those other UNIX systems where it appears.
207
208       SIGIO (which is not specified in POSIX.1-2001) is ignored by default on
209       several other UNIX systems.
210
211   Queueing and delivery semantics for standard signals
212       If multiple standard signals are pending for a process,  the  order  in
213       which the signals are delivered is unspecified.
214
215       Standard  signals  do  not  queue.  If multiple instances of a standard
216       signal are generated while  that  signal  is  blocked,  then  only  one
217       instance  of  the  signal  is marked as pending (and the signal will be
218       delivered just once when it is unblocked).  In the case where  a  stan‐
219       dard  signal  is  already  pending, the siginfo_t structure (see sigac‐
220       tion(2)) associated with that signal is not overwritten on  arrival  of
221       subsequent  instances  of  the  same  signal.   Thus,  the process will
222       receive the information associated with the first instance of the  sig‐
223       nal.
224
225   Signal numbering for standard signals
226       The  numeric  value  for  each  signal is given in the table below.  As
227       shown in the table, many signals have different numeric values on  dif‐
228       ferent  architectures.  The first numeric value in each table row shows
229       the signal number on x86, ARM, and most other architectures; the second
230       value  is  for  Alpha and SPARC; the third is for MIPS; and the last is
231       for PARISC.  A dash (-) denotes that a signal is absent on  the  corre‐
232       sponding architecture.
233
234       Signal        x86/ARM     Alpha/   MIPS   PARISC   Notes
235                   most others   SPARC
236       ─────────────────────────────────────────────────────────────────
237       SIGHUP           1           1       1       1
238       SIGINT           2           2       2       2
239       SIGQUIT          3           3       3       3
240       SIGILL           4           4       4       4
241       SIGTRAP          5           5       5       5
242       SIGABRT          6           6       6       6
243       SIGIOT           6           6       6       6
244       SIGBUS           7          10      10      10
245       SIGEMT           -           7       7      -
246       SIGFPE           8           8       8       8
247       SIGKILL          9           9       9       9
248       SIGUSR1         10          30      16      16
249       SIGSEGV         11          11      11      11
250       SIGUSR2         12          31      17      17
251       SIGPIPE         13          13      13      13
252       SIGALRM         14          14      14      14
253       SIGTERM         15          15      15      15
254       SIGSTKFLT       16          -       -        7
255       SIGCHLD         17          20      18      18
256       SIGCLD           -          -       18      -
257       SIGCONT         18          19      25      26
258       SIGSTOP         19          17      23      24
259       SIGTSTP         20          18      24      25
260       SIGTTIN         21          21      26      27
261       SIGTTOU         22          22      27      28
262       SIGURG          23          16      21      29
263       SIGXCPU         24          24      30      12
264       SIGXFSZ         25          25      31      30
265       SIGVTALRM       26          26      28      20
266       SIGPROF         27          27      29      21
267       SIGWINCH        28          28      20      23
268
269       SIGIO           29          23      22      22
270       SIGPOLL                                            Same as SIGIO
271       SIGPWR          30         29/-     19      19
272       SIGINFO          -         29/-     -       -
273       SIGLOST          -         -/29     -       -
274       SIGSYS          31          12      12      31
275       SIGUNUSED       31          -       -       31
276
277       Note the following:
278
279       *  Where  defined,  SIGUNUSED  is  synonymous with SIGSYS.  Since glibc
280          2.26, SIGUNUSED is no longer defined on any architecture.
281
282       *  Signal 29 is SIGINFO/SIGPWR (synonyms for the same value)  on  Alpha
283          but SIGLOST on SPARC.
284
285   Real-time signals
286       Starting  with  version 2.2, Linux supports real-time signals as origi‐
287       nally defined in the POSIX.1b real-time extensions (and now included in
288       POSIX.1-2001).   The range of supported real-time signals is defined by
289       the macros SIGRTMIN and SIGRTMAX.  POSIX.1-2001 requires that an imple‐
290       mentation support at least _POSIX_RTSIG_MAX (8) real-time signals.
291
292       The  Linux  kernel  supports a range of 33 different real-time signals,
293       numbered 32 to 64.  However, the  glibc  POSIX  threads  implementation
294       internally  uses  two  (for NPTL) or three (for LinuxThreads) real-time
295       signals (see pthreads(7)), and adjusts the value of  SIGRTMIN  suitably
296       (to 34 or 35).  Because the range of available real-time signals varies
297       according to the glibc threading implementation (and this variation can
298       occur  at  run  time  according to the available kernel and glibc), and
299       indeed the range of real-time signals varies across UNIX systems,  pro‐
300       grams should never refer to real-time signals using hard-coded numbers,
301       but instead should always refer to real-time signals using the notation
302       SIGRTMIN+n, and include suitable (run-time) checks that SIGRTMIN+n does
303       not exceed SIGRTMAX.
304
305       Unlike standard signals, real-time signals have no predefined meanings:
306       the entire set of real-time signals can be used for application-defined
307       purposes.
308
309       The default action for an unhandled real-time signal  is  to  terminate
310       the receiving process.
311
312       Real-time signals are distinguished by the following:
313
314       1.  Multiple  instances  of  real-time  signals can be queued.  By con‐
315           trast, if multiple instances of a  standard  signal  are  delivered
316           while  that  signal is currently blocked, then only one instance is
317           queued.
318
319       2.  If the signal is sent  using  sigqueue(3),  an  accompanying  value
320           (either  an  integer or a pointer) can be sent with the signal.  If
321           the receiving process establishes a handler for this  signal  using
322           the  SA_SIGINFO  flag to sigaction(2), then it can obtain this data
323           via the si_value field of the siginfo_t  structure  passed  as  the
324           second argument to the handler.  Furthermore, the si_pid and si_uid
325           fields of this structure can be used to obtain  the  PID  and  real
326           user ID of the process sending the signal.
327
328       3.  Real-time  signals  are  delivered in a guaranteed order.  Multiple
329           real-time signals of the same type are delivered in the order  they
330           were  sent.   If different real-time signals are sent to a process,
331           they  are  delivered  starting  with  the  lowest-numbered  signal.
332           (I.e.,  low-numbered  signals have highest priority.)  By contrast,
333           if multiple standard signals are pending for a process,  the  order
334           in which they are delivered is unspecified.
335
336       If both standard and real-time signals are pending for a process, POSIX
337       leaves it unspecified which is delivered first.  Linux, like many other
338       implementations, gives priority to standard signals in this case.
339
340       According   to   POSIX,   an  implementation  should  permit  at  least
341       _POSIX_SIGQUEUE_MAX (32) real-time signals to be queued to  a  process.
342       However, Linux does things differently.  In kernels up to and including
343       2.6.7, Linux imposes a system-wide limit on the number of queued  real-
344       time  signals  for  all  processes.  This limit can be viewed and (with
345       privilege) changed via the /proc/sys/kernel/rtsig-max file.  A  related
346       file, /proc/sys/kernel/rtsig-nr, can be used to find out how many real-
347       time signals are currently queued.  In Linux 2.6.8, these /proc  inter‐
348       faces  were  replaced  by  the  RLIMIT_SIGPENDING resource limit, which
349       specifies a per-user limit for queued  signals;  see  setrlimit(2)  for
350       further details.
351
352       The  addition  of real-time signals required the widening of the signal
353       set structure (sigset_t) from 32 to  64  bits.   Consequently,  various
354       system  calls  were  superseded  by new system calls that supported the
355       larger signal sets.  The old and new system calls are as follows:
356
357       Linux 2.0 and earlier   Linux 2.2 and later
358       sigaction(2)            rt_sigaction(2)
359       sigpending(2)           rt_sigpending(2)
360       sigprocmask(2)          rt_sigprocmask(2)
361       sigreturn(2)            rt_sigreturn(2)
362       sigsuspend(2)           rt_sigsuspend(2)
363       sigtimedwait(2)         rt_sigtimedwait(2)
364
365   Interruption of system calls and library functions by signal handlers
366       If a signal handler is invoked while a system call or library  function
367       call is blocked, then either:
368
369       * the call is automatically restarted after the signal handler returns;
370         or
371
372       * the call fails with the error EINTR.
373
374       Which of these two  behaviors  occurs  depends  on  the  interface  and
375       whether  or not the signal handler was established using the SA_RESTART
376       flag (see sigaction(2)).  The details vary across UNIX systems;  below,
377       the details for Linux.
378
379       If  a blocked call to one of the following interfaces is interrupted by
380       a signal handler, then the call is automatically  restarted  after  the
381       signal  handler  returns if the SA_RESTART flag was used; otherwise the
382       call fails with the error EINTR:
383
384       * read(2), readv(2), write(2), writev(2), and ioctl(2) calls on  "slow"
385         devices.   A "slow" device is one where the I/O call may block for an
386         indefinite time, for example, a terminal, pipe, or socket.  If an I/O
387         call  on  a slow device has already transferred some data by the time
388         it is interrupted by a signal handler, then the call  will  return  a
389         success  status  (normally,  the  number of bytes transferred).  Note
390         that a (local) disk is not a slow device according  to  this  defini‐
391         tion; I/O operations on disk devices are not interrupted by signals.
392
393       * open(2), if it can block (e.g., when opening a FIFO; see fifo(7)).
394
395       * wait(2), wait3(2), wait4(2), waitid(2), and waitpid(2).
396
397       * Socket   interfaces:  accept(2),  connect(2),  recv(2),  recvfrom(2),
398         recvmmsg(2), recvmsg(2), send(2), sendto(2), and sendmsg(2), unless a
399         timeout has been set on the socket (see below).
400
401       * File  locking  interfaces: flock(2) and the F_SETLKW and F_OFD_SETLKW
402         operations of fcntl(2)
403
404       * POSIX message queue  interfaces:  mq_receive(3),  mq_timedreceive(3),
405         mq_send(3), and mq_timedsend(3).
406
407       * futex(2)  FUTEX_WAIT  (since  Linux 2.6.22; beforehand, always failed
408         with EINTR).
409
410       * getrandom(2).
411
412       * pthread_mutex_lock(3), pthread_cond_wait(3), and related APIs.
413
414       * futex(2) FUTEX_WAIT_BITSET.
415
416       * POSIX semaphore interfaces: sem_wait(3) and  sem_timedwait(3)  (since
417         Linux 2.6.22; beforehand, always failed with EINTR).
418
419       * read(2)  from an inotify(7) file descriptor (since Linux 3.8; before‐
420         hand, always failed with EINTR).
421
422       The following interfaces are never restarted after being interrupted by
423       a signal handler, regardless of the use of SA_RESTART; they always fail
424       with the error EINTR when interrupted by a signal handler:
425
426       * "Input" socket interfaces, when a timeout (SO_RCVTIMEO) has been  set
427         on  the  socket using setsockopt(2): accept(2), recv(2), recvfrom(2),
428         recvmmsg(2) (also with a non-NULL timeout argument), and recvmsg(2).
429
430       * "Output" socket interfaces, when a timeout (SO_RCVTIMEO) has been set
431         on  the  socket  using setsockopt(2): connect(2), send(2), sendto(2),
432         and sendmsg(2).
433
434       * Interfaces used to wait for signals:  pause(2),  sigsuspend(2),  sig‐
435         timedwait(2), and sigwaitinfo(2).
436
437       * File     descriptor     multiplexing    interfaces:    epoll_wait(2),
438         epoll_pwait(2), poll(2), ppoll(2), select(2), and pselect(2).
439
440       * System V IPC interfaces: msgrcv(2), msgsnd(2), semop(2), and semtime‐
441         dop(2).
442
443       * Sleep interfaces: clock_nanosleep(2), nanosleep(2), and usleep(3).
444
445       * io_getevents(2).
446
447       The  sleep(3) function is also never restarted if interrupted by a han‐
448       dler, but gives a success return: the number of  seconds  remaining  to
449       sleep.
450
451   Interruption of system calls and library functions by stop signals
452       On  Linux,  even  in  the  absence of signal handlers, certain blocking
453       interfaces can fail with the error EINTR after the process  is  stopped
454       by one of the stop signals and then resumed via SIGCONT.  This behavior
455       is not sanctioned by POSIX.1, and doesn't occur on other systems.
456
457       The Linux interfaces that display this behavior are:
458
459       * "Input" socket interfaces, when a timeout (SO_RCVTIMEO) has been  set
460         on  the  socket using setsockopt(2): accept(2), recv(2), recvfrom(2),
461         recvmmsg(2) (also with a non-NULL timeout argument), and recvmsg(2).
462
463       * "Output" socket interfaces, when a timeout (SO_RCVTIMEO) has been set
464         on  the  socket  using setsockopt(2): connect(2), send(2), sendto(2),
465         and sendmsg(2), if a send timeout (SO_SNDTIMEO) has been set.
466
467       * epoll_wait(2), epoll_pwait(2).
468
469       * semop(2), semtimedop(2).
470
471       * sigtimedwait(2), sigwaitinfo(2).
472
473       * Linux 3.7 and earlier: read(2) from an inotify(7) file descriptor
474
475       * Linux 2.6.21  and  earlier:  futex(2)  FUTEX_WAIT,  sem_timedwait(3),
476         sem_wait(3).
477
478       * Linux 2.6.8 and earlier: msgrcv(2), msgsnd(2).
479
480       * Linux 2.4 and earlier: nanosleep(2).
481

CONFORMING TO

483       POSIX.1, except as noted.
484

NOTES

486       For a discussion of async-signal-safe functions, see signal-safety(7).
487
488       The  /proc/[pid]/task/[tid]/status  file  contains  various fields that
489       show the signals that a thread is blocking (SigBlk), catching (SigCgt),
490       or  ignoring  (SigIgn).  (The set of signals that are caught or ignored
491       will be the same across all threads in a process.)  Other  fields  show
492       the  set of pending signals that are directed to the thread (SigPnd) as
493       well as the set of pending signals that are directed to the process  as
494       a  whole (ShdPnd).  The corresponding fields in /proc/[pid]/status show
495       the information for the main thread.  See proc(5) for further details.
496

SEE ALSO

498       kill(1),   clone(2),   getrlimit(2),    kill(2),    restart_syscall(2),
499       rt_sigqueueinfo(2),  setitimer(2),  setrlimit(2),  sgetmask(2),  sigac‐
500       tion(2), sigaltstack(2), signal(2),  signalfd(2),  sigpending(2),  sig‐
501       procmask(2),  sigreturn(2),  sigsuspend(2),  sigwaitinfo(2),  abort(3),
502       bsd_signal(3), killpg(3),  longjmp(3),  pthread_sigqueue(3),  raise(3),
503       sigqueue(3),  sigset(3),  sigsetops(3),  sigvec(3), sigwait(3), strsig‐
504       nal(3),  sysv_signal(3),  core(5),   proc(5),   nptl(7),   pthreads(7),
505       sigevent(7)
506

COLOPHON

508       This  page  is  part of release 5.02 of the Linux man-pages project.  A
509       description of the project, information about reporting bugs,  and  the
510       latest     version     of     this    page,    can    be    found    at
511       https://www.kernel.org/doc/man-pages/.
512
513
514
515Linux                             2019-08-02                         SIGNAL(7)
Impressum