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