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