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-10-05 "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.
87 inherits a copy of its parent's signal dispositions.
90 the dispositions of handled signals are reset to the default;
91 the dispositions of ignored signals are left unchanged.
93 The following system calls and library functions allow
94 the caller to send a signal:
97 Sends a signal to the calling thread.
100 Sends a signal to a specified process,
101 to all members of a specified process group,
102 or to all processes on the system.
105 Sends a signal to all of the members of a specified process group.
108 Sends a signal to a specified POSIX thread in the same process as
112 Sends a signal to a specified thread within a specific process.
113 (This is the system call used to implement
114 .BR pthread_kill (3).)
117 Sends a real-time signal with accompanying data to a specified process.
118 .SS "Signal Mask and Pending Signals"
121 which means that it will not be delivered until it is later unblocked.
122 Between the time when it is generated and when it is delivered
123 a signal is said to be
126 Each thread in a process has an independent
128 which indicates the set of signals that the thread is currently blocking.
129 A thread can manipulate its signal mask using
130 .BR pthread_sigmask (3).
131 In a traditional single-threaded application,
133 can be used to manipulate the signal mask.
137 inherits a copy of its parent's signal mask;
138 the signal mask is preserved across
141 A signal may be generated (and thus pending)
142 for a process as a whole (e.g., when sent using
144 or for a specific thread (e.g., certain signals,
150 consequence of executing a specific machine-language instruction
151 are thread directed, as are signals targeted at a specific thread using
152 .BR pthread_kill (3)).
153 A process-directed signal may be delivered to any one of the
154 threads that does not currently have the signal blocked.
155 If more than one of the threads has the signal unblocked, then the
156 kernel chooses an arbitrary thread to which to deliver the signal.
158 A thread can obtain the set of signals that it currently has pending
161 This set will consist of the union of the set of pending
162 process-directed signals and the set of signals pending for
167 initially has an empty pending signal set;
168 the pending signal set is preserved across an
170 .SS "Standard Signals"
171 Linux supports the standard signals listed below.
172 Several signal numbers
173 are architecture-dependent, as indicated in the "Value" column.
174 (Where three values are given, the first one is usually valid for
176 the middle one for ix86, ia64, ppc, s390, arm and sh,
177 and the last one for mips.
178 .\" parisc is a law unto itself
179 A \- denotes that a signal is absent on the corresponding architecture.)
181 First the signals described in the original POSIX.1-1990 standard.
186 Signal Value Action Comment
187 SIGHUP \01 Term Hangup detected on controlling terminal
188 or death of controlling process
189 SIGINT \02 Term Interrupt from keyboard
190 SIGQUIT \03 Core Quit from keyboard
191 SIGILL \04 Core Illegal Instruction
192 SIGABRT \06 Core Abort signal from \fBabort\fP(3)
193 SIGFPE \08 Core Floating point exception
194 SIGKILL \09 Term Kill signal
195 SIGSEGV 11 Core Invalid memory reference
196 SIGPIPE 13 Term Broken pipe: write to pipe with no
198 SIGALRM 14 Term Timer signal from \fBalarm\fP(2)
199 SIGTERM 15 Term Termination signal
200 SIGUSR1 30,10,16 Term User-defined signal 1
201 SIGUSR2 31,12,17 Term User-defined signal 2
202 SIGCHLD 20,17,18 Ign Child stopped or terminated
203 SIGCONT 19,18,25 Cont Continue if stopped
204 SIGSTOP 17,19,23 Stop Stop process
205 SIGTSTP 18,20,24 Stop Stop typed at tty
206 SIGTTIN 21,21,26 Stop tty input for background process
207 SIGTTOU 22,22,27 Stop tty output for background process
214 cannot be caught, blocked, or ignored.
216 Next the signals not in the POSIX.1-1990 standard but described in
217 SUSv2 and POSIX.1-2001.
222 Signal Value Action Comment
223 SIGBUS 10,7,10 Core Bus error (bad memory access)
224 SIGPOLL Term Pollable event (Sys V).
225 Synonym for \fBSIGIO\fP
226 SIGPROF 27,27,29 Term Profiling timer expired
227 SIGSYS 12,\-,12 Core Bad argument to routine (SVr4)
228 SIGTRAP 5 Core Trace/breakpoint trap
229 SIGURG 16,23,21 Ign Urgent condition on socket (4.2BSD)
230 SIGVTALRM 26,26,28 Term Virtual alarm clock (4.2BSD)
231 SIGXCPU 24,24,30 Core CPU time limit exceeded (4.2BSD)
232 SIGXFSZ 25,25,31 Core File size limit exceeded (4.2BSD)
235 Up to and including Linux 2.2, the default behavior for
236 .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ ", "
237 and (on architectures other than SPARC and MIPS)
239 was to terminate the process (without a core dump).
240 (On some other Unix systems the default action for
241 .BR SIGXCPU " and " SIGXFSZ
242 is to terminate the process without a core dump.)
243 Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals,
244 terminating the process with a core dump.
246 Next various other signals.
251 Signal Value Action Comment
252 SIGIOT 6 Core IOT trap. A synonym for \fBSIGABRT\fP
254 SIGSTKFLT \-,16,\- Term Stack fault on coprocessor (unused)
255 SIGIO 23,29,22 Term I/O now possible (4.2BSD)
256 SIGCLD \-,\-,18 Ign A synonym for \fBSIGCHLD\fP
257 SIGPWR 29,30,19 Term Power failure (System V)
258 SIGINFO 29,\-,\- A synonym for \fBSIGPWR\fP
259 SIGLOST \-,\-,\- Term File lock lost
260 SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun)
261 SIGUNUSED \-,31,\- Term Unused signal (will be \fBSIGSYS\fP)
273 is not specified in POSIX.1-2001, but nevertheless appears
274 on most other Unix systems,
275 where its default action is typically to terminate
276 the process with a core dump.
279 (which is not specified in POSIX.1-2001) is typically ignored
280 by default on those other Unix systems where it appears.
283 (which is not specified in POSIX.1-2001) is ignored by default
284 on several other Unix systems.
285 .SS "Real-time Signals"
286 Linux supports real-time signals as originally defined in the POSIX.1b
287 real-time extensions (and now included in POSIX.1-2001).
288 The range of supported real-time signals is defined by the macros
292 POSIX.1-2001 requires that an implementation support at least
294 (8) real-time signals.
296 The Linux kernel supports a range of 32 different real-time
297 signals, numbered 33 to 64.
298 However, the glibc POSIX threads implementation internally uses
299 two (for NPTL) or three (for LinuxThreads) real-time signals
302 and adjusts the value of
304 suitably (to 34 or 35).
305 Because the range of available real-time signals varies according
306 to the glibc threading implementation (and this variation can occur
307 at run time according to the available kernel and glibc),
308 and indeed the range of real-time signals varies across Unix systems,
310 .IR "never refer to real-time signals using hard-coded numbers" ,
311 but instead should always refer to real-time signals using the notation
313 and include suitable (run-time) checks that
318 Unlike standard signals, real-time signals have no predefined meanings:
319 the entire set of real-time signals can be used for application-defined
321 (Note, however, that the LinuxThreads implementation uses the first
322 three real-time signals.)
324 The default action for an unhandled real-time signal is to terminate the
327 Real-time signals are distinguished by the following:
329 Multiple instances of real-time signals can be queued.
330 By contrast, if multiple instances of a standard signal are delivered
331 while that signal is currently blocked, then only one instance is queued.
333 If the signal is sent using
335 an accompanying value (either an integer or a pointer) can be sent
337 If the receiving process establishes a handler for this signal using the
341 then it can obtain this data via the
345 structure passed as the second argument to the handler.
350 fields of this structure can be used to obtain the PID
351 and real user ID of the process sending the signal.
353 Real-time signals are delivered in a guaranteed order.
354 Multiple real-time signals of the same type are delivered in the order
356 If different real-time signals are sent to a process, they are delivered
357 starting with the lowest-numbered signal.
358 (I.e., low-numbered signals have highest priority.)
359 By contrast, if multiple standard signals are pending for a process,
360 the order in which they are delivered is unspecified.
362 If both standard and real-time signals are pending for a process,
363 POSIX leaves it unspecified which is delivered first.
364 Linux, like many other implementations, gives priority
365 to standard signals in this case.
367 According to POSIX, an implementation should permit at least
368 .B _POSIX_SIGQUEUE_MAX
369 (32) real-time signals to be queued to
371 However, Linux does things differently.
372 In kernels up to and including 2.6.7, Linux imposes
373 a system-wide limit on the number of queued real-time signals
375 This limit can be viewed and (with privilege) changed via the
376 .I /proc/sys/kernel/rtsig-max
379 .IR /proc/sys/kernel/rtsig-nr ,
380 can be used to find out how many real-time signals are currently queued.
381 In Linux 2.6.8, these
383 interfaces were replaced by the
385 resource limit, which specifies a per-user limit for queued
389 .SS "Async-signal-safe functions"
391 A signal handling routine established by
395 must be very careful, since processing elsewhere may be interrupted
396 at some arbitrary point in the execution of the program.
397 POSIX has the concept of "safe function".
398 If a signal interrupts the execution of an unsafe function, and
400 calls an unsafe function, then the behavior of the program is undefined.
402 POSIX.1-2004 (also known as POSIX.1-2001 Technical Corrigendum 2)
403 requires an implementation to guarantee that the following
404 functions can be safely called inside a signal handler:
529 POSIX.1-2008 removes fpathconf(), pathconf(), and sysconf()
530 from the above list, and adds the following functions:
556 .SS Interruption of System Calls and Library Functions by Signal Handlers
557 If a signal handler is invoked while a system call or library
558 function call is blocked, then either:
560 the call is automatically restarted after the signal handler returns; or
562 the call fails with the error
565 Which of these two behaviors occurs depends on the interface and
566 whether or not the signal handler was established using the
570 The details vary across Unix systems;
571 below, the details for Linux.
573 If a blocked call to one of the following interfaces is interrupted
574 by a signal handler, then the call will be automatically restarted
575 after the signal handler returns if the
577 flag was used; otherwise the call will fail with the error
579 .\" The following system calls use ERESTARTSYS,
580 .\" so that they are restartable
589 calls on "slow" devices.
590 A "slow" device is one where the I/O call may block for an
591 indefinite time, for example, a terminal, pipe, or socket.
592 (A disk is not a slow device according to this definition.)
593 If an I/O call on a slow device has already transferred some
594 data by the time it is interrupted by a signal handler,
595 then the call will return a success status
596 (normally, the number of bytes transferred).
599 if it can block (e.g., when opening a FIFO; see
610 .\" If a timeout (setsockopt()) is in effect on the socket, then these
611 .\" system calls switch to using EINTR. Consequently, they and are not
612 .\" automatically restarted, and they show the stop/cont behavior
613 .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)
624 File locking interfaces:
630 POSIX message queue interfaces:
632 .BR mq_timedreceive (3),
635 .BR mq_timedsend (3).
639 (since Linux 2.6.22; beforehand, always failed with
642 POSIX semaphore interfaces:
645 .BR sem_timedwait (3)
646 (since Linux 2.6.22; beforehand, always failed with
650 The following interfaces are never restarted after
651 being interrupted by a signal handler,
652 regardless of the use of
654 they always fail with the error
656 when interrupted by a signal handler:
657 .\" These are the system calls that give EINTR or ERESTARTNOHAND
658 .\" on interruption by a signal handler.
661 Interfaces used to wait for signals:
664 .BR sigtimedwait (2),
668 File descriptor multiplexing interfaces:
677 System V IPC interfaces:
678 .\" On some other systems, SA_RESTART does restart these system calls
686 .BR clock_nanosleep (2),
696 .BR io_getevents (2).
701 function is also never restarted if interrupted by a handler,
702 but gives a success return: the number of seconds remaining to sleep.
703 .SS Interruption of System Calls and Library Functions by Stop Signals
704 On Linux, even in the absence of signal handlers,
705 certain blocking interfaces can fail with the error
707 after the process is stopped by one of the stop signals
710 This behavior is not sanctioned by POSIX.1, and doesn't occur
713 The Linux interfaces that display this behavior are:
722 .BR sigtimedwait (2),
730 Linux 2.6.21 and earlier:
733 .BR sem_timedwait (3),
736 Linux 2.6.8 and earlier:
740 Linux 2.4 and earlier:
744 POSIX.1, except as noted.
750 The latter is commented out in the kernel source, but
751 the build process of some software still thinks that