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 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified Sat Jul 24 17:34:08 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Sun Jan 7 01:41:27 1996 by Andries Brouwer (aeb@cwi.nl)
29 .\" Modified Sun Apr 14 12:02:29 1996 by Andries Brouwer (aeb@cwi.nl)
30 .\" Modified Sat Nov 13 16:28:23 1999 by Andries Brouwer (aeb@cwi.nl)
31 .\" Modified 10 Apr 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
32 .\" Modified 7 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Added information on real-time signals
34 .\" Modified 13 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
35 .\" Noted that SIGSTKFLT is in fact unused
36 .\" 2004-12-03, Modified mtk, added notes on RLIMIT_SIGPENDING
37 .\" 2006-04-24, mtk, Added text on changing signal dispositions,
38 .\" signal mask, and pending signals.
40 .\" Added section on system call restarting (SA_RESTART)
41 .\" Added section on stop/cont signals interrupting syscalls.
43 .TH SIGNAL 7 2008-07-07 "Linux" "Linux Programmer's Manual"
45 signal \- list of available signals
47 Linux supports both POSIX reliable signals (hereinafter
48 "standard signals") and POSIX real-time signals.
49 .SS "Signal Dispositions"
50 Each signal has a current
52 which determines how the process behaves when it is delivered
55 The entries in the "Action" column of the tables below specify
56 the default disposition for each signal, as follows:
58 Default action is to terminate the process.
60 Default action is to ignore the signal.
62 Default action is to terminate the process and dump core (see
65 Default action is to stop the process.
67 Default action is to continue the process if it is currently stopped.
69 A process can change the disposition of a signal using
73 Using these system calls, a process can elect one of the
74 following behaviors to occur on delivery of the signal:
75 perform the default action; ignore the signal;
76 or catch the signal with a
77 .IR "signal handler" ,
78 a programmer-defined function that is automatically invoked
79 when the signal is delivered.
81 The signal disposition is a per-process attribute:
82 in a multithreaded application, the disposition of a
83 particular signal is the same for all threads.
84 .SS "Signal Mask and Pending Signals"
87 which means that it will not be delivered until it is later unblocked.
88 Between the time when it is generated and when it is delivered
89 a signal is said to be
92 Each thread in a process has an independent
94 which indicates the set of signals that the thread is currently blocking.
95 A thread can manipulate its signal mask using
96 .BR pthread_sigmask (3).
97 In a traditional single-threaded application,
99 can be used to manipulate the signal mask.
101 A signal may be generated (and thus pending)
102 for a process as a whole (e.g., when sent using
104 or for a specific thread (e.g., certain signals,
110 consequence of executing a specific machine-language instruction
111 are thread directed, as are signals targeted at a specific thread using
112 .BR pthread_kill (3)).
113 A process-directed signal may be delivered to any one of the
114 threads that does not currently have the signal blocked.
115 If more than one of the threads has the signal unblocked, then the
116 kernel chooses an arbitrary thread to which to deliver the signal.
118 A thread can obtain the set of signals that it currently has pending
121 This set will consist of the union of the set of pending
122 process-directed signals and the set of signals pending for
124 .SS "Standard Signals"
125 Linux supports the standard signals listed below.
126 Several signal numbers
127 are architecture-dependent, as indicated in the "Value" column.
128 (Where three values are given, the first one is usually valid for
130 the middle one for ix86, ia64, ppc, s390, arm and sh,
131 and the last one for mips.
132 .\" parisc is a law unto itself
133 A \- denotes that a signal is absent on the corresponding architecture.)
135 First the signals described in the original POSIX.1-1990 standard.
140 Signal Value Action Comment
141 SIGHUP \01 Term Hangup detected on controlling terminal
142 or death of controlling process
143 SIGINT \02 Term Interrupt from keyboard
144 SIGQUIT \03 Core Quit from keyboard
145 SIGILL \04 Core Illegal Instruction
146 SIGABRT \06 Core Abort signal from \fBabort\fP(3)
147 SIGFPE \08 Core Floating point exception
148 SIGKILL \09 Term Kill signal
149 SIGSEGV 11 Core Invalid memory reference
150 SIGPIPE 13 Term Broken pipe: write to pipe with no
152 SIGALRM 14 Term Timer signal from \fBalarm\fP(2)
153 SIGTERM 15 Term Termination signal
154 SIGUSR1 30,10,16 Term User-defined signal 1
155 SIGUSR2 31,12,17 Term User-defined signal 2
156 SIGCHLD 20,17,18 Ign Child stopped or terminated
157 SIGCONT 19,18,25 Cont Continue if stopped
158 SIGSTOP 17,19,23 Stop Stop process
159 SIGTSTP 18,20,24 Stop Stop typed at tty
160 SIGTTIN 21,21,26 Stop tty input for background process
161 SIGTTOU 22,22,27 Stop tty output for background process
168 cannot be caught, blocked, or ignored.
170 Next the signals not in the POSIX.1-1990 standard but described in
171 SUSv2 and POSIX.1-2001.
176 Signal Value Action Comment
177 SIGBUS 10,7,10 Core Bus error (bad memory access)
178 SIGPOLL Term Pollable event (Sys V).
179 Synonym for \fBSIGIO\fP
180 SIGPROF 27,27,29 Term Profiling timer expired
181 SIGSYS 12,\-,12 Core Bad argument to routine (SVr4)
182 SIGTRAP 5 Core Trace/breakpoint trap
183 SIGURG 16,23,21 Ign Urgent condition on socket (4.2BSD)
184 SIGVTALRM 26,26,28 Term Virtual alarm clock (4.2BSD)
185 SIGXCPU 24,24,30 Core CPU time limit exceeded (4.2BSD)
186 SIGXFSZ 25,25,31 Core File size limit exceeded (4.2BSD)
189 Up to and including Linux 2.2, the default behavior for
190 .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ ", "
191 and (on architectures other than SPARC and MIPS)
193 was to terminate the process (without a core dump).
194 (On some other Unix systems the default action for
195 .BR SIGXCPU " and " SIGXFSZ
196 is to terminate the process without a core dump.)
197 Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals,
198 terminating the process with a core dump.
200 Next various other signals.
205 Signal Value Action Comment
206 SIGIOT 6 Core IOT trap. A synonym for \fBSIGABRT\fP
208 SIGSTKFLT \-,16,\- Term Stack fault on coprocessor (unused)
209 SIGIO 23,29,22 Term I/O now possible (4.2BSD)
210 SIGCLD \-,\-,18 Ign A synonym for \fBSIGCHLD\fP
211 SIGPWR 29,30,19 Term Power failure (System V)
212 SIGINFO 29,\-,\- A synonym for \fBSIGPWR\fP
213 SIGLOST \-,\-,\- Term File lock lost
214 SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun)
215 SIGUNUSED \-,31,\- Term Unused signal (will be \fBSIGSYS\fP)
227 is not specified in POSIX.1-2001, but nevertheless appears
228 on most other Unix systems,
229 where its default action is typically to terminate
230 the process with a core dump.
233 (which is not specified in POSIX.1-2001) is typically ignored
234 by default on those other Unix systems where it appears.
237 (which is not specified in POSIX.1-2001) is ignored by default
238 on several other Unix systems.
239 .SS "Real-time Signals"
240 Linux supports real-time signals as originally defined in the POSIX.1b
241 real-time extensions (and now included in POSIX.1-2001).
242 The range of supported real-time signals is defined by the macros
246 POSIX.1-2001 requires that an implementation support at least
248 (8) real-time signals.
250 The Linux kernel supports a range of 32 different real-time
251 signals, numbered 33 to 64.
252 However, the glibc POSIX threads implementation internally uses
253 two (for NPTL) or three (for LinuxThreads) real-time signals
256 and adjusts the value of
258 suitably (to 34 or 35).
259 Because the range of available real-time signals varies according
260 to the glibc threading implementation (and this variation can occur
261 at run time according to the available kernel and glibc),
262 and indeed the range of real-time signals varies across Unix systems,
264 .IR "never refer to real-time signals using hard-coded numbers" ,
265 but instead should always refer to real-time signals using the notation
267 and include suitable (run-time) checks that
272 Unlike standard signals, real-time signals have no predefined meanings:
273 the entire set of real-time signals can be used for application-defined
275 (Note, however, that the LinuxThreads implementation uses the first
276 three real-time signals.)
278 The default action for an unhandled real-time signal is to terminate the
281 Real-time signals are distinguished by the following:
283 Multiple instances of real-time signals can be queued.
284 By contrast, if multiple instances of a standard signal are delivered
285 while that signal is currently blocked, then only one instance is queued.
287 If the signal is sent using
289 an accompanying value (either an integer or a pointer) can be sent
291 If the receiving process establishes a handler for this signal using the
295 then it can obtain this data via the
299 structure passed as the second argument to the handler.
304 fields of this structure can be used to obtain the PID
305 and real user ID of the process sending the signal.
307 Real-time signals are delivered in a guaranteed order.
308 Multiple real-time signals of the same type are delivered in the order
310 If different real-time signals are sent to a process, they are delivered
311 starting with the lowest-numbered signal.
312 (I.e., low-numbered signals have highest priority.)
313 By contrast, if multiple standard signals are pending for a process,
314 the order in which they are delivered is unspecified.
316 If both standard and real-time signals are pending for a process,
317 POSIX leaves it unspecified which is delivered first.
318 Linux, like many other implementations, gives priority
319 to standard signals in this case.
321 According to POSIX, an implementation should permit at least
322 .B _POSIX_SIGQUEUE_MAX
323 (32) real-time signals to be queued to
325 However, Linux does things differently.
326 In kernels up to and including 2.6.7, Linux imposes
327 a system-wide limit on the number of queued real-time signals
329 This limit can be viewed and (with privilege) changed via the
330 .I /proc/sys/kernel/rtsig-max
333 .IR /proc/sys/kernel/rtsig-nr ,
334 can be used to find out how many real-time signals are currently queued.
335 In Linux 2.6.8, these
337 interfaces were replaced by the
339 resource limit, which specifies a per-user limit for queued
343 .SS "Async-signal-safe functions"
345 A signal handling routine established by
349 must be very careful, since processing elsewhere may be interrupted
350 at some arbitrary point in the execution of the program.
351 POSIX has the concept of "safe function".
352 If a signal interrupts the execution of an unsafe function, and
354 calls an unsafe function, then the behavior of the program is undefined.
356 POSIX.1-2004 (also known as POSIX.1-2001 Technical Corrigendum 2)
357 requires an implementation to guarantee that the following
358 functions can be safely called inside a signal handler:
359 .\" FIXME . SUSv4 adds functions to this list, and removes a few.
483 .SS Interruption of System Calls and Library Functions by Signal Handlers
484 If a signal handler is invoked while a system call or library
485 function call is blocked, then either:
487 the call is automatically restarted after the signal handler returns; or
489 the call fails with the error
492 Which of these two behaviors occurs depends on the interface and
493 whether or not the signal handler was established using the
497 The details vary across Unix systems;
498 below, the details for Linux.
500 If a blocked call to one of the following interfaces is interrupted
501 by a signal handler, then the call will be automatically restarted
502 after the signal handler returns if the
504 flag was used; otherwise the call will fail with the error
506 .\" The following system calls use ERESTARTSYS,
507 .\" so that they are restartable
516 calls on "slow" devices.
517 A "slow" device is one where the I/O call may block for an
518 indefinite time, for example, a terminal, pipe, or socket.
519 (A disk is not a slow device according to this definition.)
520 If an I/O call on a slow device has already transferred some
521 data by the time it is interrupted by a signal handler,
522 then the call will return a success status
523 (normally, the number of bytes transferred).
526 if it can block (e.g., when opening a FIFO; see
537 .\" If a timeout (setsockopt()) is in effect on the socket, then these
538 .\" system calls switch to using EINTR. Consequently, they and are not
539 .\" automatically restarted, and they show the stop/cont behavior
540 .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)
551 File locking interfaces:
557 POSIX message queue interfaces:
559 .BR mq_timedreceive (3),
562 .BR mq_timedsend (3).
566 (since Linux 2.6.22; beforehand, always failed with
569 POSIX semaphore interfaces:
572 .BR sem_timedwait (3)
573 (since Linux 2.6.22; beforehand, always failed with
577 The following interfaces are never restarted after
578 being interrupted by a signal handler,
579 regardless of the use of
581 they always fail with the error
583 when interrupted by a signal handler:
584 .\" These are the system calls that give EINTR or ERESTARTNOHAND
585 .\" on interruption by a signal handler.
588 Interfaces used to wait for signals:
591 .BR sigtimedwait (2),
595 File descriptor multiplexing interfaces:
604 System V IPC interfaces:
605 .\" On some other systems, SA_RESTART does restart these system calls
613 .BR clock_nanosleep (2),
623 .BR io_getevents (2).
628 function is also never restarted if interrupted by a handler,
629 but gives a success return: the number of seconds remaining to sleep.
630 .SS Interruption of System Calls and Library Functions by Stop Signals
631 On Linux, even in the absence of signal handlers,
632 certain blocking interfaces can fail with the error
634 after the process is stopped by one of the stop signals
637 This behavior is not sanctioned by POSIX.1, and doesn't occur
640 The Linux interfaces that display this behavior are:
649 .BR sigtimedwait (2),
657 Linux 2.6.21 and earlier:
660 .BR sem_timedwait (3),
663 Linux 2.6.8 and earlier:
667 Linux 2.4 and earlier:
671 POSIX.1, except as noted.
677 The latter is commented out in the kernel source, but
678 the build process of some software still thinks that