]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/signal.7
signal.7: Relocate Michal Sekletar's text
[thirdparty/man-pages.git] / man7 / signal.7
1 '\" t
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>
6 .\"
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.
11 .\"
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.
16 .\"
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
23 .\" professionally.
24 .\"
25 .\" Formatted or processed versions of this manual, if unaccompanied by
26 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" %%%LICENSE_END
28 .\"
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.
41 .\" 2008-07-04, mtk:
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
45 .\"
46 .TH SIGNAL 7 2019-03-06 "Linux" "Linux Programmer's Manual"
47 .SH NAME
48 signal \- overview of signals
49 .SH DESCRIPTION
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
54 .IR disposition ,
55 which determines how the process behaves when it is delivered
56 the signal.
57 .PP
58 The entries in the "Action" column of the table below specify
59 the default disposition for each signal, as follows:
60 .IP Term
61 Default action is to terminate the process.
62 .IP Ign
63 Default action is to ignore the signal.
64 .IP Core
65 Default action is to terminate the process and dump core (see
66 .BR core (5)).
67 .IP Stop
68 Default action is to stop the process.
69 .IP Cont
70 Default action is to continue the process if it is currently stopped.
71 .PP
72 A process can change the disposition of a signal using
73 .BR sigaction (2)
74 or
75 .BR signal (2).
76 (The latter is less portable when establishing a signal handler;
77 see
78 .BR signal (2)
79 for details.)
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
88 normal process stack.
89 It is possible to arrange that the signal handler
90 uses an alternate stack; see
91 .BR sigaltstack (2)
92 for a discussion of how to do this and when it might be useful.)
93 .PP
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.
97 .PP
98 A child created via
99 .BR fork (2)
100 inherits a copy of its parent's signal dispositions.
101 During an
102 .BR execve (2),
103 the dispositions of handled signals are reset to the default;
104 the dispositions of ignored signals are left unchanged.
105 .SS Sending a signal
106 The following system calls and library functions allow
107 the caller to send a signal:
108 .TP 16
109 .BR raise (3)
110 Sends a signal to the calling thread.
111 .TP
112 .BR kill (2)
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.
116 .TP
117 .BR killpg (3)
118 Sends a signal to all of the members of a specified process group.
119 .TP
120 .BR pthread_kill (3)
121 Sends a signal to a specified POSIX thread in the same process as
122 the caller.
123 .TP
124 .BR tgkill (2)
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).)
128 .TP
129 .BR sigqueue (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
133 thread until a signal is caught
134 (or an unhandled signal terminates the process):
135 .TP 16
136 .BR pause (2)
137 Suspends execution until any signal is caught.
138 .TP
139 .BR sigsuspend (2)
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:
149 .IP * 2
150 .BR sigwaitinfo (2),
151 .BR sigtimedwait (2),
152 and
153 .BR sigwait (3)
154 suspend execution until one of the signals in a specified
155 set is delivered.
156 Each of these calls returns information about the delivered signal.
157 .IP *
158 .BR signalfd (2)
159 returns a file descriptor that can be used to read information
160 about signals that are delivered to the caller.
161 Each
162 .BR read (2)
163 from this file descriptor blocks until one of the signals
164 in the set specified in the
165 .BR signalfd (2)
166 call is delivered to the caller.
167 The buffer returned by
168 .BR read (2)
169 contains a structure describing the signal.
170 .SS Signal mask and pending signals
171 A signal may be
172 .IR blocked ,
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
176 .IR pending .
177 .PP
178 Each thread in a process has an independent
179 .IR "signal mask" ,
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,
184 .BR sigprocmask (2)
185 can be used to manipulate the signal mask.
186 .PP
187 A child created via
188 .BR fork (2)
189 inherits a copy of its parent's signal mask;
190 the signal mask is preserved across
191 .BR execve (2).
192 .PP
193 A signal may be generated (and thus pending)
194 for a process as a whole (e.g., when sent using
195 .BR kill (2))
196 or for a specific thread (e.g., certain signals,
197 such as
198 .B SIGSEGV
199 and
200 .BR SIGFPE ,
201 generated as a
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.
209 .PP
210 A thread can obtain the set of signals that it currently has pending
211 using
212 .BR sigpending (2).
213 This set will consist of the union of the set of pending
214 process-directed signals and the set of signals pending for
215 the calling thread.
216 .PP
217 A child created via
218 .BR fork (2)
219 initially has an empty pending signal set;
220 the pending signal set is preserved across an
221 .BR execve (2).
222 .SS Standard signals
223 Linux supports the standard signals listed below.
224 The second column of the table indicates which standard (if any)
225 specified the signal: "P1990" indicates that the signal is described
226 in the original POSIX.1-1990 standard;
227 "P2001" indicates that the signal was added in SUSv2 and POSIX.1-2001.
228 .TS
229 l c c l
230 ____
231 lB c c l.
232 Signal Standard Action Comment
233 SIGABRT P1990 Core Abort signal from \fBabort\fP(3)
234 SIGALRM P1990 Term Timer signal from \fBalarm\fP(2)
235 SIGBUS P2001 Core Bus error (bad memory access)
236 SIGCHLD P1990 Ign Child stopped or terminated
237 SIGCLD \- Ign A synonym for \fBSIGCHLD\fP
238 SIGCONT P1990 Cont Continue if stopped
239 SIGEMT \- Term Emulator trap
240 SIGFPE P1990 Core Floating-point exception
241 SIGHUP P1990 Term Hangup detected on controlling terminal
242 or death of controlling process
243 SIGILL P1990 Core Illegal Instruction
244 SIGINFO \- A synonym for \fBSIGPWR\fP
245 SIGINT P1990 Term Interrupt from keyboard
246 SIGIO \- Term I/O now possible (4.2BSD)
247 SIGIOT \- Core IOT trap. A synonym for \fBSIGABRT\fP
248 SIGKILL P1990 Term Kill signal
249 SIGLOST \- Term File lock lost (unused)
250 SIGPIPE P1990 Term Broken pipe: write to pipe with no
251 readers; see \fBpipe\fP(7)
252 SIGPOLL P2001 Term Pollable event (Sys V).
253 Synonym for \fBSIGIO\fP
254 SIGPROF P2001 Term Profiling timer expired
255 SIGPWR \- Term Power failure (System V)
256 SIGQUIT P1990 Core Quit from keyboard
257 SIGSEGV P1990 Core Invalid memory reference
258 SIGSTKFLT \- Term Stack fault on coprocessor (unused)
259 SIGSTOP P1990 Stop Stop process
260 SIGTSTP P1990 Stop Stop typed at terminal
261 SIGSYS P2001 Core Bad system call (SVr4);
262 see also \fBseccomp\fP(2)
263 SIGTERM P1990 Term Termination signal
264 SIGTRAP P2001 Core Trace/breakpoint trap
265 SIGTTIN P1990 Stop Terminal input for background process
266 SIGTTOU P1990 Stop Terminal output for background process
267 SIGUNUSED \- Core Synonymous with \fBSIGSYS\fP
268 SIGURG P2001 Ign Urgent condition on socket (4.2BSD)
269 SIGUSR1 P1990 Term User-defined signal 1
270 SIGUSR2 P1990 Term User-defined signal 2
271 SIGVTALRM P2001 Term Virtual alarm clock (4.2BSD)
272 SIGXCPU P2001 Core CPU time limit exceeded (4.2BSD);
273 see \fBsetrlimit\fP(2)
274 SIGXFSZ P2001 Core File size limit exceeded (4.2BSD);
275 see \fBsetrlimit\fP(2)
276 SIGWINCH \- Ign Window resize signal (4.3BSD, Sun)
277 .TE
278 .PP
279 The signals
280 .B SIGKILL
281 and
282 .B SIGSTOP
283 cannot be caught, blocked, or ignored.
284 .PP
285 Up to and including Linux 2.2, the default behavior for
286 .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ ", "
287 and (on architectures other than SPARC and MIPS)
288 .B SIGBUS
289 was to terminate the process (without a core dump).
290 (On some other UNIX systems the default action for
291 .BR SIGXCPU " and " SIGXFSZ
292 is to terminate the process without a core dump.)
293 Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals,
294 terminating the process with a core dump.
295 .PP
296 .PP
297 .B SIGEMT
298 is not specified in POSIX.1-2001, but nevertheless appears
299 on most other UNIX systems,
300 where its default action is typically to terminate
301 the process with a core dump.
302 .PP
303 .B SIGPWR
304 (which is not specified in POSIX.1-2001) is typically ignored
305 by default on those other UNIX systems where it appears.
306 .PP
307 .B SIGIO
308 (which is not specified in POSIX.1-2001) is ignored by default
309 on several other UNIX systems.
310 .\"
311 .SS Queueing and delivery semantics for standard signals
312 If multiple standard signals are pending for a process,
313 the order in which the signals are delivered is unspecified.
314 .PP
315 Standard signals do not queue.
316 If multiple instances of a standard signal are generated while
317 that signal is blocked,
318 then only one instance of the signal is marked as pending
319 (and the signal will be delivered just once when it is unblocked).
320 Note that the
321 .I siginfo_t
322 structure associated with the signal already in queue is not overwritten
323 on arrival of subsequent instances of the same signal hence the process would
324 receive metadata associated with the first instance of the signal.
325 .\"
326 .SS Signal numbering for standard signals
327 The numeric value for each signal is given in the table below.
328 As shown in the table, many signals have different numeric values
329 on different architectures.
330 The first numeric value in each table row shows the signal number
331 on x86, ARM, and most other architectures;
332 the second value is for Alpha and SPARC; the third is for MIPS;
333 and the last is for PARISC.
334 A dash (\-) denotes that a signal is absent on the corresponding architecture.
335 .TS
336 l c c c c l
337 l c c c c l
338 ______
339 lB c c c c l.
340 Signal x86/ARM Alpha/ MIPS PARISC Notes
341 most others SPARC
342 SIGHUP \01 \01 \01 \01
343 SIGINT \02 \02 \02 \02
344 SIGQUIT \03 \03 \03 \03
345 SIGILL \04 \04 \04 \04
346 SIGTRAP \05 \05 \05 \05
347 SIGABRT \06 \06 \06 \06
348 SIGIOT \06 \06 \06 \06
349 SIGBUS \07 10 10 10
350 SIGEMT \- \07 \07 -
351 SIGFPE \08 \08 \08 \08
352 SIGKILL \09 \09 \09 \09
353 SIGUSR1 10 30 16 16
354 SIGSEGV 11 11 11 11
355 SIGUSR2 12 31 17 17
356 SIGPIPE 13 13 13 13
357 SIGALRM 14 14 14 14
358 SIGTERM 15 15 15 15
359 SIGSTKFLT 16 \- \- \07
360 SIGCHLD 17 20 18 18
361 SIGCLD \- \- 18 \-
362 SIGCONT 18 19 25 26
363 SIGSTOP 19 17 23 24
364 SIGTSTP 20 18 24 25
365 SIGTTIN 21 21 26 27
366 SIGTTOU 22 22 27 28
367 SIGURG 23 16 21 29
368 SIGXCPU 24 24 30 12
369 SIGXFSZ 25 25 31 30
370 SIGVTALRM 26 26 28 20
371 SIGPROF 27 27 29 21
372 SIGWINCH 28 28 20 23
373 SIGIO 29 23 22 22
374 SIGPOLL Same as SIGIO
375 SIGPWR 30 29/\- 19 19
376 SIGINFO \- 29/\- \- \-
377 SIGLOST \- \-/29 \- \-
378 SIGSYS 31 12 12 31
379 SIGUNUSED 31 \- \- 31
380 .TE
381 .PP
382 Note the following:
383 .IP * 3
384 Where defined,
385 .B SIGUNUSED
386 is synonymous with
387 .BR SIGSYS .
388 Since glibc 2.26,
389 .B SIGUNUSED
390 is no longer defined on any architecture.
391 .IP *
392 Signal 29 is
393 .BR SIGINFO / SIGPWR
394 (synonyms for the same value) on Alpha but
395 .B SIGLOST
396 on SPARC.
397 .\"
398 .SS Real-time signals
399 Starting with version 2.2,
400 Linux supports real-time signals as originally defined in the POSIX.1b
401 real-time extensions (and now included in POSIX.1-2001).
402 The range of supported real-time signals is defined by the macros
403 .B SIGRTMIN
404 and
405 .BR SIGRTMAX .
406 POSIX.1-2001 requires that an implementation support at least
407 .B _POSIX_RTSIG_MAX
408 (8) real-time signals.
409 .PP
410 The Linux kernel supports a range of 33 different real-time
411 signals, numbered 32 to 64.
412 However, the glibc POSIX threads implementation internally uses
413 two (for NPTL) or three (for LinuxThreads) real-time signals
414 (see
415 .BR pthreads (7)),
416 and adjusts the value of
417 .B SIGRTMIN
418 suitably (to 34 or 35).
419 Because the range of available real-time signals varies according
420 to the glibc threading implementation (and this variation can occur
421 at run time according to the available kernel and glibc),
422 and indeed the range of real-time signals varies across UNIX systems,
423 programs should
424 .IR "never refer to real-time signals using hard-coded numbers" ,
425 but instead should always refer to real-time signals using the notation
426 .BR SIGRTMIN +n,
427 and include suitable (run-time) checks that
428 .BR SIGRTMIN +n
429 does not exceed
430 .BR SIGRTMAX .
431 .PP
432 Unlike standard signals, real-time signals have no predefined meanings:
433 the entire set of real-time signals can be used for application-defined
434 purposes.
435 .PP
436 The default action for an unhandled real-time signal is to terminate the
437 receiving process.
438 .PP
439 Real-time signals are distinguished by the following:
440 .IP 1. 4
441 Multiple instances of real-time signals can be queued.
442 By contrast, if multiple instances of a standard signal are delivered
443 while that signal is currently blocked, then only one instance is queued.
444 .IP 2. 4
445 If the signal is sent using
446 .BR sigqueue (3),
447 an accompanying value (either an integer or a pointer) can be sent
448 with the signal.
449 If the receiving process establishes a handler for this signal using the
450 .B SA_SIGINFO
451 flag to
452 .BR sigaction (2),
453 then it can obtain this data via the
454 .I si_value
455 field of the
456 .I siginfo_t
457 structure passed as the second argument to the handler.
458 Furthermore, the
459 .I si_pid
460 and
461 .I si_uid
462 fields of this structure can be used to obtain the PID
463 and real user ID of the process sending the signal.
464 .IP 3. 4
465 Real-time signals are delivered in a guaranteed order.
466 Multiple real-time signals of the same type are delivered in the order
467 they were sent.
468 If different real-time signals are sent to a process, they are delivered
469 starting with the lowest-numbered signal.
470 (I.e., low-numbered signals have highest priority.)
471 By contrast, if multiple standard signals are pending for a process,
472 the order in which they are delivered is unspecified.
473 .PP
474 If both standard and real-time signals are pending for a process,
475 POSIX leaves it unspecified which is delivered first.
476 Linux, like many other implementations, gives priority
477 to standard signals in this case.
478 .PP
479 According to POSIX, an implementation should permit at least
480 .B _POSIX_SIGQUEUE_MAX
481 (32) real-time signals to be queued to
482 a process.
483 However, Linux does things differently.
484 In kernels up to and including 2.6.7, Linux imposes
485 a system-wide limit on the number of queued real-time signals
486 for all processes.
487 This limit can be viewed and (with privilege) changed via the
488 .I /proc/sys/kernel/rtsig-max
489 file.
490 A related file,
491 .IR /proc/sys/kernel/rtsig-nr ,
492 can be used to find out how many real-time signals are currently queued.
493 In Linux 2.6.8, these
494 .I /proc
495 interfaces were replaced by the
496 .B RLIMIT_SIGPENDING
497 resource limit, which specifies a per-user limit for queued
498 signals; see
499 .BR setrlimit (2)
500 for further details.
501 .PP
502 The addition of real-time signals required the widening
503 of the signal set structure
504 .RI ( sigset_t )
505 from 32 to 64 bits.
506 Consequently, various system calls were superseded by new system calls
507 that supported the larger signal sets.
508 The old and new system calls are as follows:
509 .TS
510 lb lb
511 l l.
512 Linux 2.0 and earlier Linux 2.2 and later
513 \fBsigaction\fP(2) \fBrt_sigaction\fP(2)
514 \fBsigpending\fP(2) \fBrt_sigpending\fP(2)
515 \fBsigprocmask\fP(2) \fBrt_sigprocmask\fP(2)
516 \fBsigreturn\fP(2) \fBrt_sigreturn\fP(2)
517 \fBsigsuspend\fP(2) \fBrt_sigsuspend\fP(2)
518 \fBsigtimedwait\fP(2) \fBrt_sigtimedwait\fP(2)
519 .TE
520 .\"
521 .SS Interruption of system calls and library functions by signal handlers
522 If a signal handler is invoked while a system call or library
523 function call is blocked, then either:
524 .IP * 2
525 the call is automatically restarted after the signal handler returns; or
526 .IP *
527 the call fails with the error
528 .BR EINTR .
529 .PP
530 Which of these two behaviors occurs depends on the interface and
531 whether or not the signal handler was established using the
532 .BR SA_RESTART
533 flag (see
534 .BR sigaction (2)).
535 The details vary across UNIX systems;
536 below, the details for Linux.
537 .PP
538 If a blocked call to one of the following interfaces is interrupted
539 by a signal handler, then the call is automatically restarted
540 after the signal handler returns if the
541 .BR SA_RESTART
542 flag was used; otherwise the call fails with the error
543 .BR EINTR :
544 .\" The following system calls use ERESTARTSYS,
545 .\" so that they are restartable
546 .IP * 2
547 .BR read (2),
548 .BR readv (2),
549 .BR write (2),
550 .BR writev (2),
551 and
552 .BR ioctl (2)
553 calls on "slow" devices.
554 A "slow" device is one where the I/O call may block for an
555 indefinite time, for example, a terminal, pipe, or socket.
556 If an I/O call on a slow device has already transferred some
557 data by the time it is interrupted by a signal handler,
558 then the call will return a success status
559 (normally, the number of bytes transferred).
560 Note that a (local) disk is not a slow device according to this definition;
561 I/O operations on disk devices are not interrupted by signals.
562 .IP *
563 .BR open (2),
564 if it can block (e.g., when opening a FIFO; see
565 .BR fifo (7)).
566 .IP *
567 .BR wait (2),
568 .BR wait3 (2),
569 .BR wait4 (2),
570 .BR waitid (2),
571 and
572 .BR waitpid (2).
573 .IP *
574 Socket interfaces:
575 .\" If a timeout (setsockopt()) is in effect on the socket, then these
576 .\" system calls switch to using EINTR. Consequently, they and are not
577 .\" automatically restarted, and they show the stop/cont behavior
578 .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)
579 .BR accept (2),
580 .BR connect (2),
581 .BR recv (2),
582 .BR recvfrom (2),
583 .BR recvmmsg (2),
584 .BR recvmsg (2),
585 .BR send (2),
586 .BR sendto (2),
587 and
588 .BR sendmsg (2),
589 .\" FIXME What about sendmmsg()?
590 unless a timeout has been set on the socket (see below).
591 .IP *
592 File locking interfaces:
593 .BR flock (2)
594 and
595 the
596 .BR F_SETLKW
597 and
598 .BR F_OFD_SETLKW
599 operations of
600 .BR fcntl (2)
601 .IP *
602 POSIX message queue interfaces:
603 .BR mq_receive (3),
604 .BR mq_timedreceive (3),
605 .BR mq_send (3),
606 and
607 .BR mq_timedsend (3).
608 .IP *
609 .BR futex (2)
610 .B FUTEX_WAIT
611 (since Linux 2.6.22;
612 .\" commit 72c1bbf308c75a136803d2d76d0e18258be14c7a
613 beforehand, always failed with
614 .BR EINTR ).
615 .IP *
616 .BR getrandom (2).
617 .IP *
618 .BR pthread_mutex_lock (3),
619 .BR pthread_cond_wait (3),
620 and related APIs.
621 .IP *
622 .BR futex (2)
623 .BR FUTEX_WAIT_BITSET .
624 .IP *
625 POSIX semaphore interfaces:
626 .BR sem_wait (3)
627 and
628 .BR sem_timedwait (3)
629 (since Linux 2.6.22;
630 .\" as a consequence of the 2.6.22 changes in the futex() implementation
631 beforehand, always failed with
632 .BR EINTR ).
633 .IP *
634 .BR read (2)
635 from an
636 .BR inotify (7)
637 file descriptor
638 (since Linux 3.8;
639 .\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
640 beforehand, always failed with
641 .BR EINTR ).
642 .PP
643 The following interfaces are never restarted after
644 being interrupted by a signal handler,
645 regardless of the use of
646 .BR SA_RESTART ;
647 they always fail with the error
648 .B EINTR
649 when interrupted by a signal handler:
650 .\" These are the system calls that give EINTR or ERESTARTNOHAND
651 .\" on interruption by a signal handler.
652 .IP * 2
653 "Input" socket interfaces, when a timeout
654 .RB ( SO_RCVTIMEO )
655 has been set on the socket using
656 .BR setsockopt (2):
657 .BR accept (2),
658 .BR recv (2),
659 .BR recvfrom (2),
660 .BR recvmmsg (2)
661 (also with a non-NULL
662 .IR timeout
663 argument),
664 and
665 .BR recvmsg (2).
666 .IP *
667 "Output" socket interfaces, when a timeout
668 .RB ( SO_RCVTIMEO )
669 has been set on the socket using
670 .BR setsockopt (2):
671 .BR connect (2),
672 .BR send (2),
673 .BR sendto (2),
674 and
675 .BR sendmsg (2).
676 .\" FIXME What about sendmmsg()?
677 .IP *
678 Interfaces used to wait for signals:
679 .BR pause (2),
680 .BR sigsuspend (2),
681 .BR sigtimedwait (2),
682 and
683 .BR sigwaitinfo (2).
684 .IP *
685 File descriptor multiplexing interfaces:
686 .BR epoll_wait (2),
687 .BR epoll_pwait (2),
688 .BR poll (2),
689 .BR ppoll (2),
690 .BR select (2),
691 and
692 .BR pselect (2).
693 .IP *
694 System V IPC interfaces:
695 .\" On some other systems, SA_RESTART does restart these system calls
696 .BR msgrcv (2),
697 .BR msgsnd (2),
698 .BR semop (2),
699 and
700 .BR semtimedop (2).
701 .IP *
702 Sleep interfaces:
703 .BR clock_nanosleep (2),
704 .BR nanosleep (2),
705 and
706 .BR usleep (3).
707 .IP *
708 .BR io_getevents (2).
709 .PP
710 The
711 .BR sleep (3)
712 function is also never restarted if interrupted by a handler,
713 but gives a success return: the number of seconds remaining to sleep.
714 .SS Interruption of system calls and library functions by stop signals
715 On Linux, even in the absence of signal handlers,
716 certain blocking interfaces can fail with the error
717 .BR EINTR
718 after the process is stopped by one of the stop signals
719 and then resumed via
720 .BR SIGCONT .
721 This behavior is not sanctioned by POSIX.1, and doesn't occur
722 on other systems.
723 .PP
724 The Linux interfaces that display this behavior are:
725 .IP * 2
726 "Input" socket interfaces, when a timeout
727 .RB ( SO_RCVTIMEO )
728 has been set on the socket using
729 .BR setsockopt (2):
730 .BR accept (2),
731 .BR recv (2),
732 .BR recvfrom (2),
733 .BR recvmmsg (2)
734 (also with a non-NULL
735 .IR timeout
736 argument),
737 and
738 .BR recvmsg (2).
739 .IP *
740 "Output" socket interfaces, when a timeout
741 .RB ( SO_RCVTIMEO )
742 has been set on the socket using
743 .BR setsockopt (2):
744 .BR connect (2),
745 .BR send (2),
746 .BR sendto (2),
747 and
748 .\" FIXME What about sendmmsg()?
749 .BR sendmsg (2),
750 if a send timeout
751 .RB ( SO_SNDTIMEO )
752 has been set.
753 .IP * 2
754 .BR epoll_wait (2),
755 .BR epoll_pwait (2).
756 .IP *
757 .BR semop (2),
758 .BR semtimedop (2).
759 .IP *
760 .BR sigtimedwait (2),
761 .BR sigwaitinfo (2).
762 .IP *
763 Linux 3.7 and earlier:
764 .BR read (2)
765 from an
766 .BR inotify (7)
767 file descriptor
768 .\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
769 .IP *
770 Linux 2.6.21 and earlier:
771 .BR futex (2)
772 .BR FUTEX_WAIT ,
773 .BR sem_timedwait (3),
774 .BR sem_wait (3).
775 .IP *
776 Linux 2.6.8 and earlier:
777 .BR msgrcv (2),
778 .BR msgsnd (2).
779 .IP *
780 Linux 2.4 and earlier:
781 .BR nanosleep (2).
782 .SH CONFORMING TO
783 POSIX.1, except as noted.
784 .\" It must be a *very* long time since this was true:
785 .\" .SH BUGS
786 .\" .B SIGIO
787 .\" and
788 .\" .B SIGLOST
789 .\" have the same value.
790 .\" The latter is commented out in the kernel source, but
791 .\" the build process of some software still thinks that
792 .\" signal 29 is
793 .\" .BR SIGLOST .
794 .SH NOTES
795 For a discussion of async-signal-safe functions, see
796 .BR signal-safety (7).
797 .PP
798 The
799 .I /proc/[pid]/task/[tid]/status
800 file contains various fields that show the signals
801 that a thread is blocking
802 .RI ( SigBlk ),
803 catching
804 .RI ( SigCgt ),
805 or ignoring
806 .RI ( SigIgn ).
807 (The set of signals that are caught or ignored will be the same
808 across all threads in a process.)
809 Other fields show the set of pending signals that are directed to the thread
810 .RI ( SigPnd )
811 as well as the set of pending signals that are directed
812 to the process as a whole
813 .RI ( ShdPnd ).
814 The corresponding fields in
815 .I /proc/[pid]/status
816 show the information for the main thread.
817 See
818 .BR proc (5)
819 for further details.
820 .SH SEE ALSO
821 .BR kill (1),
822 .BR clone (2),
823 .BR getrlimit (2),
824 .BR kill (2),
825 .BR restart_syscall (2),
826 .BR rt_sigqueueinfo (2),
827 .BR setitimer (2),
828 .BR setrlimit (2),
829 .BR sgetmask (2),
830 .BR sigaction (2),
831 .BR sigaltstack (2),
832 .BR signal (2),
833 .BR signalfd (2),
834 .BR sigpending (2),
835 .BR sigprocmask (2),
836 .BR sigreturn (2),
837 .BR sigsuspend (2),
838 .BR sigwaitinfo (2),
839 .BR abort (3),
840 .BR bsd_signal (3),
841 .BR killpg (3),
842 .BR longjmp (3),
843 .BR pthread_sigqueue (3),
844 .BR raise (3),
845 .BR sigqueue (3),
846 .BR sigset (3),
847 .BR sigsetops (3),
848 .BR sigvec (3),
849 .BR sigwait (3),
850 .BR strsignal (3),
851 .BR sysv_signal (3),
852 .BR core (5),
853 .BR proc (5),
854 .BR nptl (7),
855 .BR pthreads (7),
856 .BR sigevent (7)