.\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
.\" <mtk.manpages@gmail.com>
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Modified Sat Jul 24 17:34:08 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified Sun Jan 7 01:41:27 1996 by Andries Brouwer (aeb@cwi.nl)
.\" Added section on stop/cont signals interrupting syscalls.
.\" 2008-10-05, mtk: various additions
.\"
-.TH SIGNAL 7 2010-09-19 "Linux" "Linux Programmer's Manual"
+.TH SIGNAL 7 2015-02-01 "Linux" "Linux Programmer's Manual"
.SH NAME
signal \- overview of signals
.SH DESCRIPTION
Linux supports both POSIX reliable signals (hereinafter
"standard signals") and POSIX real-time signals.
-.SS "Signal Dispositions"
+.SS Signal dispositions
Each signal has a current
.IR disposition ,
which determines how the process behaves when it is delivered
.BR execve (2),
the dispositions of handled signals are reset to the default;
the dispositions of ignored signals are left unchanged.
-.SS Sending a Signal
+.SS Sending a signal
The following system calls and library functions allow
the caller to send a signal:
.TP 16
(This is the system call used to implement
.BR pthread_kill (3).)
.TP
-.BR sigqueue (2)
+.BR sigqueue (3)
Sends a real-time signal with accompanying data to a specified process.
-.SS Waiting for a Signal to be Caught
+.SS Waiting for a signal to be caught
The following system calls suspend execution of the calling process
or thread until a signal is caught
(or an unhandled signal terminates the process):
.BR sigsuspend (2)
Temporarily changes the signal mask (see below) and suspends
execution until one of the unmasked signals is caught.
-.SS Synchronously Accepting a Signal
+.SS Synchronously accepting a signal
Rather than asynchronously catching a signal via a signal handler,
it is possible to synchronously accept the signal, that is,
to block execution until the signal is delivered,
The buffer returned by
.BR read (2)
contains a structure describing the signal.
-.SS "Signal Mask and Pending Signals"
+.SS Signal mask and pending signals
A signal may be
.IR blocked ,
which means that it will not be delivered until it is later unblocked.
initially has an empty pending signal set;
the pending signal set is preserved across an
.BR execve (2).
-.SS "Standard Signals"
+.SS Standard signals
Linux supports the standard signals listed below.
Several signal numbers
are architecture-dependent, as indicated in the "Value" column.
(Where three values are given, the first one is usually valid for
alpha and sparc,
-the middle one for ix86, ia64, ppc, s390, arm and sh,
+the middle one for x86, arm, and most other architectures,
and the last one for mips.
-.\" parisc is a law unto itself
+(Values for parisc are
+.I not
+shown; see the Linux kernel source for signal numbering on that architecture.)
A \- denotes that a signal is absent on the corresponding architecture.)
First the signals described in the original POSIX.1-1990 standard.
SIGCHLD 20,17,18 Ign Child stopped or terminated
SIGCONT 19,18,25 Cont Continue if stopped
SIGSTOP 17,19,23 Stop Stop process
-SIGTSTP 18,20,24 Stop Stop typed at tty
-SIGTTIN 21,21,26 Stop tty input for background process
-SIGTTOU 22,22,27 Stop tty output for background process
+SIGTSTP 18,20,24 Stop Stop typed at terminal
+SIGTTIN 21,21,26 Stop Terminal input for background process
+SIGTTOU 22,22,27 Stop Terminal output for background process
.TE
The signals
SIGCLD \-,\-,18 Ign A synonym for \fBSIGCHLD\fP
SIGPWR 29,30,19 Term Power failure (System V)
SIGINFO 29,\-,\- A synonym for \fBSIGPWR\fP
-SIGLOST \-,\-,\- Term File lock lost
+SIGLOST \-,\-,\- Term File lock lost (unused)
SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun)
SIGUNUSED \-,31,\- Core Synonymous with \fBSIGSYS\fP
.TE
.\" parisc is the only exception: SIGSYS is 12, SIGUNUSED is 31
.B SIGSYS
on most architectures.
-.SS "Real-time Signals"
+.SS Real-time signals
Linux supports real-time signals as originally defined in the POSIX.1b
real-time extensions (and now included in POSIX.1-2001).
The range of supported real-time signals is defined by the macros
Unlike standard signals, real-time signals have no predefined meanings:
the entire set of real-time signals can be used for application-defined
purposes.
-(Note, however, that the LinuxThreads implementation uses the first
-three real-time signals.)
.PP
The default action for an unhandled real-time signal is to terminate the
receiving process.
while that signal is currently blocked, then only one instance is queued.
.IP 2. 4
If the signal is sent using
-.BR sigqueue (2),
+.BR sigqueue (3),
an accompanying value (either an integer or a pointer) can be sent
with the signal.
If the receiving process establishes a handler for this signal using the
.B SA_SIGINFO
flag to
-.BR sigaction (2)
+.BR sigaction (2),
then it can obtain this data via the
.I si_value
field of the
signals; see
.BR setrlimit (2)
for further details.
-.SS "Async-signal-safe functions"
+.SS Async-signal-safe functions
.PP
A signal handler function must be very careful,
since processing elsewhere may be interrupted
utimes()
.fi
.in
-.SS Interruption of System Calls and Library Functions by Signal Handlers
+.SS Interruption of system calls and library functions by signal handlers
If a signal handler is invoked while a system call or library
function call is blocked, then either:
.IP * 2
A "slow" device is one where the I/O call may block for an
indefinite time, for example, a terminal, pipe, or socket.
(A disk is not a slow device according to this definition.)
+A
+.BR read (2)
+on an
+.BR eventfd (2),
+.BR signalfd (2),
+.BR timerfd (2),
+.BR fanotify (7),
+or
+.BR inotify (7)
+file descriptor is also considered to be a "slow" operation.
+(Before Linux 3.8,
+.\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
+reads from an
+.BR inotify (7)
+file descriptor were not restartable;
+when interrupted by a signal handler,
+.BR read (2)
+always failed with the error
+.BR EINTR .)
If an I/O call on a slow device has already transferred some
data by the time it is interrupted by a signal handler,
then the call will return a success status
.BR connect (2),
.BR recv (2),
.BR recvfrom (2),
+.BR recvmmsg (2),
.BR recvmsg (2),
.BR send (2),
.BR sendto (2),
and
+.\" FIXME . What about sendmmsg()?
.BR sendmsg (2),
unless a timeout has been set on the socket (see below).
.IP *
File locking interfaces:
.BR flock (2)
and
+the
+.BR F_SETLKW
+and
+.BR F_OFD_SETLKW
+operations of
.BR fcntl (2)
-.BR F_SETLKW .
.IP *
POSIX message queue interfaces:
.BR mq_receive (3),
(since Linux 2.6.22; beforehand, always failed with
.BR EINTR ).
.IP *
+.BR getrandom (2).
+.IP *
+.BR pthread_mutex_lock (3),
+.BR pthread_cond_wait (3),
+and related APIs.
+.IP *
POSIX semaphore interfaces:
.BR sem_wait (3)
and
.\" on interruption by a signal handler.
.RS 4
.IP * 2
-Socket interfaces, when a timeout has been set on the socket using
+"Input" socket interfaces, when a timeout
+.RB ( SO_RCVTIMEO )
+has been set on the socket using
.BR setsockopt (2):
.BR accept (2),
.BR recv (2),
.BR recvfrom (2),
+.BR recvmmsg (2)
+(also with a non-NULL
+.IR timeout
+argument),
and
-.BR recvmsg (2),
-if a receive timeout
-.RB ( SO_RCVTIMEO )
-has been set;
+.BR recvmsg (2).
+.IP *
+"Output" socket interfaces, when a timeout
+.RB ( SO_SNDTIMEO )
+has been set on the socket using
+.BR setsockopt (2):
.BR connect (2),
.BR send (2),
.BR sendto (2),
and
-.BR sendmsg (2),
-if a send timeout
-.RB ( SO_SNDTIMEO )
-has been set.
+.\" FIXME . What about sendmmsg()?
+.BR sendmsg (2).
.IP *
Interfaces used to wait for signals:
.BR pause (2),
and
.BR usleep (3).
.IP *
-.BR read (2)
-from an
-.BR inotify (7)
-file descriptor.
-.IP *
.BR io_getevents (2).
.RE
.PP
.BR sleep (3)
function is also never restarted if interrupted by a handler,
but gives a success return: the number of seconds remaining to sleep.
-.SS Interruption of System Calls and Library Functions by Stop Signals
+.SS Interruption of system calls and library functions by stop signals
On Linux, even in the absence of signal handlers,
certain blocking interfaces can fail with the error
.BR EINTR
The Linux interfaces that display this behavior are:
.RS 4
.IP * 2
-Socket interfaces, when a timeout has been set on the socket using
+"Input" socket interfaces, when a timeout
+.RB ( SO_RCVTIMEO )
+has been set on the socket using
.BR setsockopt (2):
.BR accept (2),
.BR recv (2),
.BR recvfrom (2),
+.BR recvmmsg (2)
+(also with a non-NULL
+.IR timeout
+argument),
and
-.BR recvmsg (2),
-if a receive timeout
-.RB ( SO_RCVTIMEO )
-has been set;
+.BR recvmsg (2).
+.IP *
+"Output" socket interfaces, when a timeout
+.RB ( SO_SNDTIMEO )
+has been set on the socket using
+.BR setsockopt (2):
.BR connect (2),
.BR send (2),
.BR sendto (2),
and
-.BR sendmsg (2),
-if a send timeout
-.RB ( SO_SNDTIMEO )
-has been set.
+.\" FIXME . What about sendmmsg()?
+.BR sendmsg (2).
.IP * 2
.BR epoll_wait (2),
.BR epoll_pwait (2).
.BR sigtimedwait (2),
.BR sigwaitinfo (2).
.IP *
+Linux 3.7 and earlier:
+.\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
.BR read (2)
from an
.BR inotify (7)
Linux 2.4 and earlier:
.BR nanosleep (2).
.RE
-.SH "CONFORMING TO"
+.SH CONFORMING TO
POSIX.1, except as noted.
-.SH BUGS
-.B SIGIO
-and
-.B SIGLOST
-have the same value.
-The latter is commented out in the kernel source, but
-the build process of some software still thinks that
-signal 29 is
-.BR SIGLOST .
-.SH "SEE ALSO"
+.\" It must be a *very* long time since this was true:
+.\" .SH BUGS
+.\" .B SIGIO
+.\" and
+.\" .B SIGLOST
+.\" have the same value.
+.\" The latter is commented out in the kernel source, but
+.\" the build process of some software still thinks that
+.\" signal 29 is
+.\" .BR SIGLOST .
+.SH SEE ALSO
.BR kill (1),
.BR getrlimit (2),
.BR kill (2),
.BR killpg (2),
+.BR restart_syscall (2),
+.BR rt_sigqueueinfo (2),
.BR setitimer (2),
.BR setrlimit (2),
.BR sgetmask (2),
.BR signalfd (2),
.BR sigpending (2),
.BR sigprocmask (2),
-.BR sigqueue (2),
+.BR sigreturn (2),
.BR sigsuspend (2),
.BR sigwaitinfo (2),
.BR abort (3),
.BR longjmp (3),
.BR raise (3),
.BR pthread_sigqueue (3),
+.BR sigqueue (3),
.BR sigset (3),
.BR sigsetops (3),
.BR sigvec (3),
.BR proc (5),
.BR pthreads (7),
.BR sigevent (7)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.