2 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" and Copyright (c) 2002, 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
5 .\" <mtk.manpages@gmail.com>
7 .\" %%%LICENSE_START(VERBATIM)
8 .\" Permission is granted to make and distribute verbatim copies of this
9 .\" manual provided the copyright notice and this permission notice are
10 .\" preserved on all copies.
12 .\" Permission is granted to copy and distribute modified versions of this
13 .\" manual under the conditions for verbatim copying, provided that the
14 .\" entire resulting derived work is distributed under the terms of a
15 .\" permission notice identical to this one.
17 .\" Since the Linux kernel and libraries are constantly changing, this
18 .\" manual page may be incorrect or out-of-date. The author(s) assume no
19 .\" responsibility for errors or omissions, or for damages resulting from
20 .\" the use of the information contained herein. The author(s) may not
21 .\" have taken the same level of care in the production of this manual,
22 .\" which is licensed free of charge, as they might when working
25 .\" Formatted or processed versions of this manual, if unaccompanied by
26 .\" the source, must acknowledge the copyright and authors of this work.
29 .\" Modified Sat Jul 24 17:34:08 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified Sun Jan 7 01:41:27 1996 by Andries Brouwer (aeb@cwi.nl)
31 .\" Modified Sun Apr 14 12:02:29 1996 by Andries Brouwer (aeb@cwi.nl)
32 .\" Modified Sat Nov 13 16:28:23 1999 by Andries Brouwer (aeb@cwi.nl)
33 .\" Modified 10 Apr 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
34 .\" Modified 7 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
35 .\" Added information on real-time signals
36 .\" Modified 13 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" Noted that SIGSTKFLT is in fact unused
38 .\" 2004-12-03, Modified mtk, added notes on RLIMIT_SIGPENDING
39 .\" 2006-04-24, mtk, Added text on changing signal dispositions,
40 .\" signal mask, and pending signals.
42 .\" Added section on system call restarting (SA_RESTART)
43 .\" Added section on stop/cont signals interrupting syscalls.
44 .\" 2008-10-05, mtk: various additions
46 .TH SIGNAL 7 2016-10-08 "Linux" "Linux Programmer's Manual"
48 signal \- overview of signals
50 Linux supports both POSIX reliable signals (hereinafter
51 "standard signals") and POSIX real-time signals.
52 .SS Signal dispositions
53 Each signal has a current
55 which determines how the process behaves when it is delivered
58 The entries in the "Action" column of the tables below specify
59 the default disposition for each signal, as follows:
61 Default action is to terminate the process.
63 Default action is to ignore the signal.
65 Default action is to terminate the process and dump core (see
68 Default action is to stop the process.
70 Default action is to continue the process if it is currently stopped.
72 A process can change the disposition of a signal using
76 (The latter is less portable when establishing a signal handler;
80 Using these system calls, a process can elect one of the
81 following behaviors to occur on delivery of the signal:
82 perform the default action; ignore the signal;
83 or catch the signal with a
84 .IR "signal handler" ,
85 a programmer-defined function that is automatically invoked
86 when the signal is delivered.
87 (By default, the signal handler is invoked on the
89 It is possible to arrange that the signal handler
90 uses an alternate stack; see
92 for a discussion of how to do this and when it might be useful.)
94 The signal disposition is a per-process attribute:
95 in a multithreaded application, the disposition of a
96 particular signal is the same for all threads.
100 inherits a copy of its parent's signal dispositions.
103 the dispositions of handled signals are reset to the default;
104 the dispositions of ignored signals are left unchanged.
106 The following system calls and library functions allow
107 the caller to send a signal:
110 Sends a signal to the calling thread.
113 Sends a signal to a specified process,
114 to all members of a specified process group,
115 or to all processes on the system.
118 Sends a signal to all of the members of a specified process group.
121 Sends a signal to a specified POSIX thread in the same process as
125 Sends a signal to a specified thread within a specific process.
126 (This is the system call used to implement
127 .BR pthread_kill (3).)
130 Sends a real-time signal with accompanying data to a specified process.
131 .SS Waiting for a signal to be caught
132 The following system calls suspend execution of the calling process
133 or thread until a signal is caught
134 (or an unhandled signal terminates the process):
137 Suspends execution until any signal is caught.
140 Temporarily changes the signal mask (see below) and suspends
141 execution until one of the unmasked signals is caught.
142 .SS Synchronously accepting a signal
143 Rather than asynchronously catching a signal via a signal handler,
144 it is possible to synchronously accept the signal, that is,
145 to block execution until the signal is delivered,
146 at which point the kernel returns information about the
147 signal to the caller.
148 There are two general ways to do this:
151 .BR sigtimedwait (2),
154 suspend execution until one of the signals in a specified
156 Each of these calls returns information about the delivered signal.
159 returns a file descriptor that can be used to read information
160 about signals that are delivered to the caller.
163 from this file descriptor blocks until one of the signals
164 in the set specified in the
166 call is delivered to the caller.
167 The buffer returned by
169 contains a structure describing the signal.
170 .SS Signal mask and pending signals
173 which means that it will not be delivered until it is later unblocked.
174 Between the time when it is generated and when it is delivered
175 a signal is said to be
178 Each thread in a process has an independent
180 which indicates the set of signals that the thread is currently blocking.
181 A thread can manipulate its signal mask using
182 .BR pthread_sigmask (3).
183 In a traditional single-threaded application,
185 can be used to manipulate the signal mask.
189 inherits a copy of its parent's signal mask;
190 the signal mask is preserved across
193 A signal may be generated (and thus pending)
194 for a process as a whole (e.g., when sent using
196 or for a specific thread (e.g., certain signals,
202 consequence of executing a specific machine-language instruction
203 are thread directed, as are signals targeted at a specific thread using
204 .BR pthread_kill (3)).
205 A process-directed signal may be delivered to any one of the
206 threads that does not currently have the signal blocked.
207 If more than one of the threads has the signal unblocked, then the
208 kernel chooses an arbitrary thread to which to deliver the signal.
210 A thread can obtain the set of signals that it currently has pending
213 This set will consist of the union of the set of pending
214 process-directed signals and the set of signals pending for
219 initially has an empty pending signal set;
220 the pending signal set is preserved across an
223 Linux supports the standard signals listed below.
224 Several signal numbers
225 are architecture-dependent, as indicated in the "Value" column.
226 (Where three values are given, the first one is usually valid for
228 the middle one for x86, arm, and most other architectures,
229 and the last one for mips.
230 (Values for parisc are
232 shown; see the Linux kernel source for signal numbering on that architecture.)
233 A \- denotes that a signal is absent on the corresponding architecture.)
235 First the signals described in the original POSIX.1-1990 standard.
240 Signal Value Action Comment
241 SIGHUP \01 Term Hangup detected on controlling terminal
242 or death of controlling process
243 SIGINT \02 Term Interrupt from keyboard
244 SIGQUIT \03 Core Quit from keyboard
245 SIGILL \04 Core Illegal Instruction
246 SIGABRT \06 Core Abort signal from \fBabort\fP(3)
247 SIGFPE \08 Core Floating point exception
248 SIGKILL \09 Term Kill signal
249 SIGSEGV 11 Core Invalid memory reference
250 SIGPIPE 13 Term Broken pipe: write to pipe with no
252 SIGALRM 14 Term Timer signal from \fBalarm\fP(2)
253 SIGTERM 15 Term Termination signal
254 SIGUSR1 30,10,16 Term User-defined signal 1
255 SIGUSR2 31,12,17 Term User-defined signal 2
256 SIGCHLD 20,17,18 Ign Child stopped or terminated
257 SIGCONT 19,18,25 Cont Continue if stopped
258 SIGSTOP 17,19,23 Stop Stop process
259 SIGTSTP 18,20,24 Stop Stop typed at terminal
260 SIGTTIN 21,21,26 Stop Terminal input for background process
261 SIGTTOU 22,22,27 Stop Terminal output for background process
268 cannot be caught, blocked, or ignored.
270 Next the signals not in the POSIX.1-1990 standard but described in
271 SUSv2 and POSIX.1-2001.
276 Signal Value Action Comment
277 SIGBUS 10,7,10 Core Bus error (bad memory access)
278 SIGPOLL Term Pollable event (Sys V).
279 Synonym for \fBSIGIO\fP
280 SIGPROF 27,27,29 Term Profiling timer expired
281 SIGSYS 12,31,12 Core Bad argument to routine (SVr4)
282 SIGTRAP 5 Core Trace/breakpoint trap
283 SIGURG 16,23,21 Ign Urgent condition on socket (4.2BSD)
284 SIGVTALRM 26,26,28 Term Virtual alarm clock (4.2BSD)
285 SIGXCPU 24,24,30 Core CPU time limit exceeded (4.2BSD)
286 SIGXFSZ 25,25,31 Core File size limit exceeded (4.2BSD)
289 Up to and including Linux 2.2, the default behavior for
290 .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ ", "
291 and (on architectures other than SPARC and MIPS)
293 was to terminate the process (without a core dump).
294 (On some other UNIX systems the default action for
295 .BR SIGXCPU " and " SIGXFSZ
296 is to terminate the process without a core dump.)
297 Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals,
298 terminating the process with a core dump.
300 Next various other signals.
305 Signal Value Action Comment
306 SIGIOT 6 Core IOT trap. A synonym for \fBSIGABRT\fP
308 SIGSTKFLT \-,16,\- Term Stack fault on coprocessor (unused)
309 SIGIO 23,29,22 Term I/O now possible (4.2BSD)
310 SIGCLD \-,\-,18 Ign A synonym for \fBSIGCHLD\fP
311 SIGPWR 29,30,19 Term Power failure (System V)
312 SIGINFO 29,\-,\- A synonym for \fBSIGPWR\fP
313 SIGLOST \-,\-,\- Term File lock lost (unused)
314 SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun)
315 SIGUNUSED \-,31,\- Core Synonymous with \fBSIGSYS\fP
327 is not specified in POSIX.1-2001, but nevertheless appears
328 on most other UNIX systems,
329 where its default action is typically to terminate
330 the process with a core dump.
333 (which is not specified in POSIX.1-2001) is typically ignored
334 by default on those other UNIX systems where it appears.
337 (which is not specified in POSIX.1-2001) is ignored by default
338 on several other UNIX systems.
343 .\" parisc is the only exception: SIGSYS is 12, SIGUNUSED is 31
345 on most architectures.
346 .SS Real-time signals
347 Starting with version 2.2,
348 Linux supports real-time signals as originally defined in the POSIX.1b
349 real-time extensions (and now included in POSIX.1-2001).
350 The range of supported real-time signals is defined by the macros
354 POSIX.1-2001 requires that an implementation support at least
356 (8) real-time signals.
358 The Linux kernel supports a range of 33 different real-time
359 signals, numbered 32 to 64.
360 However, the glibc POSIX threads implementation internally uses
361 two (for NPTL) or three (for LinuxThreads) real-time signals
364 and adjusts the value of
366 suitably (to 34 or 35).
367 Because the range of available real-time signals varies according
368 to the glibc threading implementation (and this variation can occur
369 at run time according to the available kernel and glibc),
370 and indeed the range of real-time signals varies across UNIX systems,
372 .IR "never refer to real-time signals using hard-coded numbers" ,
373 but instead should always refer to real-time signals using the notation
375 and include suitable (run-time) checks that
380 Unlike standard signals, real-time signals have no predefined meanings:
381 the entire set of real-time signals can be used for application-defined
384 The default action for an unhandled real-time signal is to terminate the
387 Real-time signals are distinguished by the following:
389 Multiple instances of real-time signals can be queued.
390 By contrast, if multiple instances of a standard signal are delivered
391 while that signal is currently blocked, then only one instance is queued.
393 If the signal is sent using
395 an accompanying value (either an integer or a pointer) can be sent
397 If the receiving process establishes a handler for this signal using the
401 then it can obtain this data via the
405 structure passed as the second argument to the handler.
410 fields of this structure can be used to obtain the PID
411 and real user ID of the process sending the signal.
413 Real-time signals are delivered in a guaranteed order.
414 Multiple real-time signals of the same type are delivered in the order
416 If different real-time signals are sent to a process, they are delivered
417 starting with the lowest-numbered signal.
418 (I.e., low-numbered signals have highest priority.)
419 By contrast, if multiple standard signals are pending for a process,
420 the order in which they are delivered is unspecified.
422 If both standard and real-time signals are pending for a process,
423 POSIX leaves it unspecified which is delivered first.
424 Linux, like many other implementations, gives priority
425 to standard signals in this case.
427 According to POSIX, an implementation should permit at least
428 .B _POSIX_SIGQUEUE_MAX
429 (32) real-time signals to be queued to
431 However, Linux does things differently.
432 In kernels up to and including 2.6.7, Linux imposes
433 a system-wide limit on the number of queued real-time signals
435 This limit can be viewed and (with privilege) changed via the
436 .I /proc/sys/kernel/rtsig-max
439 .IR /proc/sys/kernel/rtsig-nr ,
440 can be used to find out how many real-time signals are currently queued.
441 In Linux 2.6.8, these
443 interfaces were replaced by the
445 resource limit, which specifies a per-user limit for queued
450 The addition or real-time signals required the widening
451 of the signal set structure
454 Consequently, various system calls were superseded by new system calls
455 that supported the larger signal sets.
456 The old and new system calls are as follows:
460 Linux 2.0 and earlier Linux 2.2 and later
461 \fBsigaction\fP(2) \fBrt_sigaction\fP(2)
462 \fBsigpending\fP(2) \fBrt_sigpending\fP(2)
463 \fBsigprocmask\fP(2) \fBrt_sigprocmask\fP(2)
464 \fBsigreturn\fP(2) \fBrt_sigreturn\fP(2)
465 \fBsigsuspend\fP(2) \fBrt_sigsuspend\fP(2)
466 \fBsigtimedwait\fP(2) \fBrt_sigtimedwait\fP(2)
469 .SS Async-signal-safe functions
471 A signal handler function must be very careful,
472 since processing elsewhere may be interrupted
473 at some arbitrary point in the execution of the program.
474 POSIX has the concept of "safe function".
475 If a signal interrupts the execution of an unsafe function, and
477 either calls an unsafe function or
479 terminates via a call to
483 and the program subsequently calls an unsafe function,
484 then the behavior of the program is undefined.
486 POSIX.1-2004 (also known as POSIX.1-2001 Technical Corrigendum 2)
487 requires an implementation to guarantee that the following
488 functions can be safely called inside a signal handler:
613 POSIX.1-2008 removes fpathconf(), pathconf(), and sysconf()
614 from the above list, and adds the following functions:
641 POSIX.1-2008 Technical Corrigendum 1 (2013)
642 adds the following functions:
652 .\" FIXME POSIX.1-2008 TC 2 looks set to add many more async-signal-safe
653 .\" functions. Document these.
654 .SS Interruption of system calls and library functions by signal handlers
655 If a signal handler is invoked while a system call or library
656 function call is blocked, then either:
658 the call is automatically restarted after the signal handler returns; or
660 the call fails with the error
663 Which of these two behaviors occurs depends on the interface and
664 whether or not the signal handler was established using the
668 The details vary across UNIX systems;
669 below, the details for Linux.
671 If a blocked call to one of the following interfaces is interrupted
672 by a signal handler, then the call will be automatically restarted
673 after the signal handler returns if the
675 flag was used; otherwise the call will fail with the error
677 .\" The following system calls use ERESTARTSYS,
678 .\" so that they are restartable
686 calls on "slow" devices.
687 A "slow" device is one where the I/O call may block for an
688 indefinite time, for example, a terminal, pipe, or socket.
689 If an I/O call on a slow device has already transferred some
690 data by the time it is interrupted by a signal handler,
691 then the call will return a success status
692 (normally, the number of bytes transferred).
693 Note that a (local) disk is not a slow device according to this definition;
694 I/O operations on disk devices are not interrupted by signals.
697 if it can block (e.g., when opening a FIFO; see
708 .\" If a timeout (setsockopt()) is in effect on the socket, then these
709 .\" system calls switch to using EINTR. Consequently, they and are not
710 .\" automatically restarted, and they show the stop/cont behavior
711 .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)
722 .\" FIXME What about sendmmsg()?
723 unless a timeout has been set on the socket (see below).
725 File locking interfaces:
735 POSIX message queue interfaces:
737 .BR mq_timedreceive (3),
740 .BR mq_timedsend (3).
745 .\" commit 72c1bbf308c75a136803d2d76d0e18258be14c7a
746 beforehand, always failed with
751 .BR pthread_mutex_lock (3),
752 .BR pthread_cond_wait (3),
756 .BR FUTEX_WAIT_BITSET .
758 POSIX semaphore interfaces:
761 .BR sem_timedwait (3)
763 .\" as a consequence of the 2.6.22 changes in the futex() implementation
764 beforehand, always failed with
767 The following interfaces are never restarted after
768 being interrupted by a signal handler,
769 regardless of the use of
771 they always fail with the error
773 when interrupted by a signal handler:
774 .\" These are the system calls that give EINTR or ERESTARTNOHAND
775 .\" on interruption by a signal handler.
777 "Input" socket interfaces, when a timeout
779 has been set on the socket using
785 (also with a non-NULL
791 "Output" socket interfaces, when a timeout
793 has been set on the socket using
800 .\" FIXME What about sendmmsg()?
802 Interfaces used to wait for signals:
805 .BR sigtimedwait (2),
809 File descriptor multiplexing interfaces:
818 System V IPC interfaces:
819 .\" On some other systems, SA_RESTART does restart these system calls
827 .BR clock_nanosleep (2),
837 .BR io_getevents (2).
841 function is also never restarted if interrupted by a handler,
842 but gives a success return: the number of seconds remaining to sleep.
843 .SS Interruption of system calls and library functions by stop signals
844 On Linux, even in the absence of signal handlers,
845 certain blocking interfaces can fail with the error
847 after the process is stopped by one of the stop signals
850 This behavior is not sanctioned by POSIX.1, and doesn't occur
853 The Linux interfaces that display this behavior are:
855 "Input" socket interfaces, when a timeout
857 has been set on the socket using
863 (also with a non-NULL
869 "Output" socket interfaces, when a timeout
871 has been set on the socket using
877 .\" FIXME What about sendmmsg()?
889 .BR sigtimedwait (2),
897 Linux 2.6.21 and earlier:
900 .BR sem_timedwait (3),
903 Linux 2.6.8 and earlier:
907 Linux 2.4 and earlier:
910 POSIX.1, except as noted.
911 .\" It must be a *very* long time since this was true:
916 .\" have the same value.
917 .\" The latter is commented out in the kernel source, but
918 .\" the build process of some software still thinks that
925 .BR restart_syscall (2),
926 .BR rt_sigqueueinfo (2),
942 .BR pthread_sigqueue (3),