summaryrefslogtreecommitdiffstats
path: root/man7/signal.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/signal.7')
-rw-r--r--man7/signal.7372
1 files changed, 186 insertions, 186 deletions
diff --git a/man7/signal.7 b/man7/signal.7
index 4ba5306c8..0d9c34cb5 100644
--- a/man7/signal.7
+++ b/man7/signal.7
@@ -46,7 +46,7 @@ Default action is to ignore the signal.
.TP
Core
Default action is to terminate the process and dump core (see
-.BR core (5)).
+.MR core 5 ).
.TP
Stop
Default action is to stop the process.
@@ -55,12 +55,12 @@ Cont
Default action is to continue the process if it is currently stopped.
.P
A process can change the disposition of a signal using
-.BR sigaction (2)
+.MR sigaction 2
or
-.BR signal (2).
+.MR signal 2 .
(The latter is less portable when establishing a signal handler;
see
-.BR signal (2)
+.MR signal 2
for details.)
Using these system calls, a process can elect one of the
following behaviors to occur on delivery of the signal:
@@ -74,7 +74,7 @@ By default, a signal handler is invoked on the
normal process stack.
It is possible to arrange that the signal handler
uses an alternate stack; see
-.BR sigaltstack (2)
+.MR sigaltstack 2
for a discussion of how to do this and when it might be useful.
.P
The signal disposition is a per-process attribute:
@@ -82,50 +82,50 @@ in a multithreaded application, the disposition of a
particular signal is the same for all threads.
.P
A child created via
-.BR fork (2)
+.MR fork 2
inherits a copy of its parent's signal dispositions.
During an
-.BR execve (2),
+.MR execve 2 ,
the dispositions of handled signals are reset to the default;
the dispositions of ignored signals are left unchanged.
.SS Sending a signal
The following system calls and library functions allow
the caller to send a signal:
.TP
-.BR raise (3)
+.MR raise 3
Sends a signal to the calling thread.
.TP
-.BR kill (2)
+.MR kill 2
Sends a signal to a specified process,
to all members of a specified process group,
or to all processes on the system.
.TP
-.BR pidfd_send_signal (2)
+.MR pidfd_send_signal 2
Sends a signal to a process identified by a PID file descriptor.
.TP
-.BR killpg (3)
+.MR killpg 3
Sends a signal to all of the members of a specified process group.
.TP
-.BR pthread_kill (3)
+.MR pthread_kill 3
Sends a signal to a specified POSIX thread in the same process as
the caller.
.TP
-.BR tgkill (2)
+.MR tgkill 2
Sends a signal to a specified thread within a specific process.
(This is the system call used to implement
-.BR pthread_kill (3).)
+.MR pthread_kill 3 .)
.TP
-.BR sigqueue (3)
+.MR sigqueue 3
Sends a real-time signal with accompanying data to a specified process.
.SS Waiting for a signal to be caught
The following system calls suspend execution of the calling
thread until a signal is caught
(or an unhandled signal terminates the process):
.TP
-.BR pause (2)
+.MR pause 2
Suspends execution until any signal is caught.
.TP
-.BR sigsuspend (2)
+.MR sigsuspend 2
Temporarily changes the signal mask (see below) and suspends
execution until one of the unmasked signals is caught.
.\"
@@ -137,25 +137,25 @@ at which point the kernel returns information about the
signal to the caller.
There are two general ways to do this:
.IP \[bu] 3
-.BR sigwaitinfo (2),
-.BR sigtimedwait (2),
+.MR sigwaitinfo 2 ,
+.MR sigtimedwait 2 ,
and
-.BR sigwait (3)
+.MR sigwait 3
suspend execution until one of the signals in a specified
set is delivered.
Each of these calls returns information about the delivered signal.
.IP \[bu]
-.BR signalfd (2)
+.MR signalfd 2
returns a file descriptor that can be used to read information
about signals that are delivered to the caller.
Each
-.BR read (2)
+.MR read 2
from this file descriptor blocks until one of the signals
in the set specified in the
-.BR signalfd (2)
+.MR signalfd 2
call is delivered to the caller.
The buffer returned by
-.BR read (2)
+.MR read 2
contains a structure describing the signal.
.SS Signal mask and pending signals
A signal may be
@@ -169,16 +169,16 @@ Each thread in a process has an independent
.IR "signal mask" ,
which indicates the set of signals that the thread is currently blocking.
A thread can manipulate its signal mask using
-.BR pthread_sigmask (3).
+.MR pthread_sigmask 3 .
In a traditional single-threaded application,
-.BR sigprocmask (2)
+.MR sigprocmask 2
can be used to manipulate the signal mask.
.P
A child created via
-.BR fork (2)
+.MR fork 2
inherits a copy of its parent's signal mask;
the signal mask is preserved across
-.BR execve (2).
+.MR execve 2 .
.P
A signal may be process-directed or thread-directed.
A process-directed signal is one that is targeted at (and thus pending for)
@@ -186,9 +186,9 @@ the process as a whole.
A signal may be process-directed
because it was generated by the kernel for reasons
other than a hardware exception, or because it was sent using
-.BR kill (2)
+.MR kill 2
or
-.BR sigqueue (3).
+.MR sigqueue 3 .
A thread-directed signal is one that is targeted at a specific thread.
A signal may be thread-directed because it was generated as a consequence
of executing a specific machine-language instruction
@@ -199,9 +199,9 @@ for an invalid memory access, or
for a math error), or because it was
targeted at a specific thread using
interfaces such as
-.BR tgkill (2)
+.MR tgkill 2
or
-.BR pthread_kill (3).
+.MR pthread_kill 3 .
.P
A process-directed signal may be delivered to any one of the
threads that does not currently have the signal blocked.
@@ -228,16 +228,16 @@ kernel chooses an arbitrary thread to which to deliver the signal.
.P
A thread can obtain the set of signals that it currently has pending
using
-.BR sigpending (2).
+.MR sigpending 2 .
This set will consist of the union of the set of pending
process-directed signals and the set of signals pending for
the calling thread.
.P
A child created via
-.BR fork (2)
+.MR fork 2
initially has an empty pending signal set;
the pending signal set is preserved across an
-.BR execve (2).
+.MR execve 2 .
.\"
.SS Execution of signal handlers
Whenever there is a transition from kernel-mode to user-mode execution
@@ -253,11 +253,11 @@ the signal handler:
The signal is removed from the set of pending signals.
.IP (1.2)
If the signal handler was installed by a call to
-.BR sigaction (2)
+.MR sigaction 2
that specified the
.B SA_ONSTACK
flag and the thread has defined an alternate signal stack (using
-.BR sigaltstack (2)),
+.MR sigaltstack 2 ),
then that stack is installed.
.IP (1.3)
Various pieces of signal-related context are saved
@@ -278,7 +278,7 @@ the thread's alternate signal stack settings.
.RE
.IP
(If the signal handler was installed using the
-.BR sigaction (2)
+.MR sigaction 2
.B SA_SIGINFO
flag, then the above information is accessible via the
.I ucontext_t
@@ -287,7 +287,7 @@ object that is pointed to by the third argument of the signal handler.)
Any signals specified in
.I act\->sa_mask
when registering the handler with
-.BR sigprocmask (2)
+.MR sigprocmask 2
are added to the thread's signal mask.
The signal being delivered is also
added to the signal mask, unless
@@ -301,7 +301,7 @@ The kernel sets the program counter for the thread to point to the first
instruction of the signal handler function,
and configures the return address for that function to point to a piece
of user-space code known as the signal trampoline (described in
-.BR sigreturn (2)).
+.MR sigreturn 2 ).
.IP (3)
The kernel passes control back to user-space, where execution
commences at the start of the signal handler function.
@@ -309,35 +309,35 @@ commences at the start of the signal handler function.
When the signal handler returns, control passes to the signal trampoline code.
.IP (5)
The signal trampoline calls
-.BR sigreturn (2),
+.MR sigreturn 2 ,
a system call that uses the information in the stack frame created in step 1
to restore the thread to its state before the signal handler was
called.
The thread's signal mask and alternate signal stack settings
are restored as part of this procedure.
Upon completion of the call to
-.BR sigreturn (2),
+.MR sigreturn 2 ,
the kernel transfers control back to user space,
and the thread recommences execution at the point where it was
interrupted by the signal handler.
.P
Note that if the signal handler does not return
(e.g., control is transferred out of the handler using
-.BR siglongjmp (3),
+.MR siglongjmp 3 ,
or the handler executes a new program with
-.BR execve (2)),
+.MR execve 2 ),
then the final step is not performed.
In particular, in such scenarios it is the programmer's responsibility
to restore the state of the signal mask (using
-.BR sigprocmask (2)),
+.MR sigprocmask 2 ),
if it is desired to unblock the signals that were blocked on entry
to the signal handler.
(Note that
-.BR siglongjmp (3)
+.MR siglongjmp 3
may or may not restore the signal mask, depending on the
.I savesigs
value that was specified in the corresponding call to
-.BR sigsetjmp (3).)
+.MR sigsetjmp 3 .)
.P
From the kernel's point of view,
execution of the signal handler code is exactly the same as the execution
@@ -449,7 +449,7 @@ then only one instance of the signal is marked as pending
In the case where a standard signal is already pending, the
.I siginfo_t
structure (see
-.BR sigaction (2))
+.MR sigaction 2 )
associated with that signal is not overwritten
on arrival of subsequent instances of the same signal.
Thus, the process will receive the information
@@ -544,7 +544,7 @@ signals, numbered 32 to 64.
However, the glibc POSIX threads implementation internally uses
two (for NPTL) or three (for LinuxThreads) real-time signals
(see
-.BR pthreads (7)),
+.MR pthreads 7 ),
and adjusts the value of
.B SIGRTMIN
suitably (to 34 or 35).
@@ -575,13 +575,13 @@ By contrast, if multiple instances of a standard signal are delivered
while that signal is currently blocked, then only one instance is queued.
.IP \[bu]
If the signal is sent using
-.BR sigqueue (3),
+.MR 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),
+.MR sigaction 2 ,
then it can obtain this data via the
.I si_value
field of the
@@ -628,7 +628,7 @@ interfaces were replaced by the
.B RLIMIT_SIGPENDING
resource limit, which specifies a per-user limit for queued
signals; see
-.BR setrlimit (2)
+.MR setrlimit 2
for further details.
.P
The addition of real-time signals required the widening
@@ -663,7 +663,7 @@ Which of these two behaviors occurs depends on the interface and
whether or not the signal handler was established using the
.B SA_RESTART
flag (see
-.BR sigaction (2)).
+.MR sigaction 2 ).
The details vary across UNIX systems;
below, the details for Linux.
.P
@@ -676,12 +676,12 @@ flag was used; otherwise the call fails with the error
.\" The following system calls use ERESTARTSYS,
.\" so that they are restartable
.IP \[bu] 3
-.BR read (2),
-.BR readv (2),
-.BR write (2),
-.BR writev (2),
+.MR read 2 ,
+.MR readv 2 ,
+.MR write 2 ,
+.MR writev 2 ,
and
-.BR ioctl (2)
+.MR ioctl 2
calls on "slow" devices.
A "slow" device is one where the I/O call may block for an
indefinite time, for example, a terminal, pipe, or socket.
@@ -692,80 +692,80 @@ then the call will return a success status
Note that a (local) disk is not a slow device according to this definition;
I/O operations on disk devices are not interrupted by signals.
.IP \[bu]
-.BR open (2),
+.MR open 2 ,
if it can block (e.g., when opening a FIFO; see
-.BR fifo (7)).
+.MR fifo 7 ).
.IP \[bu]
-.BR wait (2),
-.BR wait3 (2),
-.BR wait4 (2),
-.BR waitid (2),
+.MR wait 2 ,
+.MR wait3 2 ,
+.MR wait4 2 ,
+.MR waitid 2 ,
and
-.BR waitpid (2).
+.MR waitpid 2 .
.IP \[bu]
Socket interfaces:
.\" If a timeout (setsockopt()) is in effect on the socket, then these
.\" system calls switch to using EINTR. Consequently, they and are not
.\" automatically restarted, and they show the stop/cont behavior
.\" described below. (Verified from Linux 2.6.26 source, and by experiment; mtk)
-.BR accept (2),
-.BR connect (2),
-.BR recv (2),
-.BR recvfrom (2),
-.BR recvmmsg (2),
-.BR recvmsg (2),
-.BR send (2),
-.BR sendto (2),
+.MR accept 2 ,
+.MR connect 2 ,
+.MR recv 2 ,
+.MR recvfrom 2 ,
+.MR recvmmsg 2 ,
+.MR recvmsg 2 ,
+.MR send 2 ,
+.MR sendto 2 ,
and
-.BR sendmsg (2),
+.MR sendmsg 2 ,
.\" FIXME What about sendmmsg()?
unless a timeout has been set on the socket (see below).
.IP \[bu]
File locking interfaces:
-.BR flock (2)
+.MR flock 2
and
the
.B F_SETLKW
and
.B F_OFD_SETLKW
operations of
-.BR fcntl (2)
+.MR fcntl 2
.IP \[bu]
POSIX message queue interfaces:
-.BR mq_receive (3),
-.BR mq_timedreceive (3),
-.BR mq_send (3),
+.MR mq_receive 3 ,
+.MR mq_timedreceive 3 ,
+.MR mq_send 3 ,
and
-.BR mq_timedsend (3).
+.MR mq_timedsend 3 .
.IP \[bu]
-.BR futex (2)
+.MR futex 2
.B FUTEX_WAIT
(since Linux 2.6.22;
.\" commit 72c1bbf308c75a136803d2d76d0e18258be14c7a
beforehand, always failed with
.BR EINTR ).
.IP \[bu]
-.BR getrandom (2).
+.MR getrandom 2 .
.IP \[bu]
-.BR pthread_mutex_lock (3),
-.BR pthread_cond_wait (3),
+.MR pthread_mutex_lock 3 ,
+.MR pthread_cond_wait 3 ,
and related APIs.
.IP \[bu]
-.BR futex (2)
+.MR futex 2
.BR FUTEX_WAIT_BITSET .
.IP \[bu]
POSIX semaphore interfaces:
-.BR sem_wait (3)
+.MR sem_wait 3
and
-.BR sem_timedwait (3)
+.MR sem_timedwait 3
(since Linux 2.6.22;
.\" as a consequence of the 2.6.22 changes in the futex() implementation
beforehand, always failed with
.BR EINTR ).
.IP \[bu]
-.BR read (2)
+.MR read 2
from an
-.BR inotify (7)
+.MR inotify 7
file descriptor
(since Linux 3.8;
.\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
@@ -785,72 +785,72 @@ when interrupted by a signal handler:
"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)
+.MR setsockopt 2 :
+.MR accept 2 ,
+.MR recv 2 ,
+.MR recvfrom 2 ,
+.MR recvmmsg 2
(also with a non-NULL
.I timeout
argument),
and
-.BR recvmsg (2).
+.MR recvmsg 2 .
.IP \[bu]
"Output" socket interfaces, when a timeout
.RB ( SO_RCVTIMEO )
has been set on the socket using
-.BR setsockopt (2):
-.BR connect (2),
-.BR send (2),
-.BR sendto (2),
+.MR setsockopt 2 :
+.MR connect 2 ,
+.MR send 2 ,
+.MR sendto 2 ,
and
-.BR sendmsg (2).
+.MR sendmsg 2 .
.\" FIXME What about sendmmsg()?
.IP \[bu]
Interfaces used to wait for signals:
-.BR pause (2),
-.BR sigsuspend (2),
-.BR sigtimedwait (2),
+.MR pause 2 ,
+.MR sigsuspend 2 ,
+.MR sigtimedwait 2 ,
and
-.BR sigwaitinfo (2).
+.MR sigwaitinfo 2 .
.IP \[bu]
File descriptor multiplexing interfaces:
-.BR epoll_wait (2),
-.BR epoll_pwait (2),
-.BR poll (2),
-.BR ppoll (2),
-.BR select (2),
+.MR epoll_wait 2 ,
+.MR epoll_pwait 2 ,
+.MR poll 2 ,
+.MR ppoll 2 ,
+.MR select 2 ,
and
-.BR pselect (2).
+.MR pselect 2 .
.IP \[bu]
System V IPC interfaces:
.\" On some other systems, SA_RESTART does restart these system calls
-.BR msgrcv (2),
-.BR msgsnd (2),
-.BR semop (2),
+.MR msgrcv 2 ,
+.MR msgsnd 2 ,
+.MR semop 2 ,
and
-.BR semtimedop (2).
+.MR semtimedop 2 .
.IP \[bu]
Sleep interfaces:
-.BR clock_nanosleep (2),
-.BR nanosleep (2),
+.MR clock_nanosleep 2 ,
+.MR nanosleep 2 ,
and
-.BR usleep (3).
+.MR usleep 3 .
.IP \[bu]
-.BR io_getevents (2).
+.MR io_getevents 2 .
.P
The
-.BR sleep (3)
+.MR sleep 3
function is also never restarted if interrupted by a handler,
but gives a success return: the number of seconds remaining to sleep.
.P
In certain circumstances, the
-.BR seccomp (2)
+.MR seccomp 2
user-space notification feature can lead to restarting of system calls
that would otherwise never be restarted by
.BR SA_RESTART ;
for details, see
-.BR seccomp_unotify (2).
+.MR seccomp_unotify 2 .
.\"
.SS Interruption of system calls and library functions by stop signals
On Linux, even in the absence of signal handlers,
@@ -867,64 +867,64 @@ The Linux interfaces that display this behavior are:
"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)
+.MR setsockopt 2 :
+.MR accept 2 ,
+.MR recv 2 ,
+.MR recvfrom 2 ,
+.MR recvmmsg 2
(also with a non-NULL
.I timeout
argument),
and
-.BR recvmsg (2).
+.MR recvmsg 2 .
.IP \[bu]
"Output" socket interfaces, when a timeout
.RB ( SO_RCVTIMEO )
has been set on the socket using
-.BR setsockopt (2):
-.BR connect (2),
-.BR send (2),
-.BR sendto (2),
+.MR setsockopt 2 :
+.MR connect 2 ,
+.MR send 2 ,
+.MR sendto 2 ,
and
.\" FIXME What about sendmmsg()?
-.BR sendmsg (2),
+.MR sendmsg 2 ,
if a send timeout
.RB ( SO_SNDTIMEO )
has been set.
.IP \[bu]
-.BR epoll_wait (2),
-.BR epoll_pwait (2).
+.MR epoll_wait 2 ,
+.MR epoll_pwait 2 .
.IP \[bu]
-.BR semop (2),
-.BR semtimedop (2).
+.MR semop 2 ,
+.MR semtimedop 2 .
.IP \[bu]
-.BR sigtimedwait (2),
-.BR sigwaitinfo (2).
+.MR sigtimedwait 2 ,
+.MR sigwaitinfo 2 .
.IP \[bu]
Linux 3.7 and earlier:
-.BR read (2)
+.MR read 2
from an
-.BR inotify (7)
+.MR inotify 7
file descriptor
.\" commit 1ca39ab9d21ac93f94b9e3eb364ea9a5cf2aba06
.IP \[bu]
Linux 2.6.21 and earlier:
-.BR futex (2)
+.MR futex 2
.BR FUTEX_WAIT ,
-.BR sem_timedwait (3),
-.BR sem_wait (3).
+.MR sem_timedwait 3 ,
+.MR sem_wait 3 .
.IP \[bu]
Linux 2.6.8 and earlier:
-.BR msgrcv (2),
-.BR msgsnd (2).
+.MR msgrcv 2 ,
+.MR msgsnd 2 .
.IP \[bu]
Linux 2.4 and earlier:
-.BR nanosleep (2).
+.MR nanosleep 2 .
.SH STANDARDS
POSIX.1, except as noted.
.SH NOTES
For a discussion of async-signal-safe functions, see
-.BR signal\-safety (7).
+.MR signal\-safety 7 .
.P
The
.IR /proc/ pid /task/ tid /status
@@ -946,7 +946,7 @@ The corresponding fields in
.IR /proc/ pid /status
show the information for the main thread.
See
-.BR proc (5)
+.MR proc 5
for further details.
.SH BUGS
There are six signals that can be delivered
@@ -979,41 +979,41 @@ even though
would make more sense,
because of how the CPU reports the forbidden operation to the kernel.
.SH SEE ALSO
-.BR kill (1),
-.BR clone (2),
-.BR getrlimit (2),
-.BR kill (2),
-.BR pidfd_send_signal (2),
-.BR restart_syscall (2),
-.BR rt_sigqueueinfo (2),
-.BR setitimer (2),
-.BR setrlimit (2),
-.BR sgetmask (2),
-.BR sigaction (2),
-.BR sigaltstack (2),
-.BR signal (2),
-.BR signalfd (2),
-.BR sigpending (2),
-.BR sigprocmask (2),
-.BR sigreturn (2),
-.BR sigsuspend (2),
-.BR sigwaitinfo (2),
-.BR abort (3),
-.BR bsd_signal (3),
-.BR killpg (3),
-.BR longjmp (3),
-.BR pthread_sigqueue (3),
-.BR raise (3),
-.BR sigqueue (3),
-.BR sigset (3),
-.BR sigsetops (3),
-.BR sigvec (3),
-.BR sigwait (3),
-.BR strsignal (3),
-.BR swapcontext (3),
-.BR sysv_signal (3),
-.BR core (5),
-.BR proc (5),
-.BR nptl (7),
-.BR pthreads (7),
-.BR sigevent (3type)
+.MR kill 1 ,
+.MR clone 2 ,
+.MR getrlimit 2 ,
+.MR kill 2 ,
+.MR pidfd_send_signal 2 ,
+.MR restart_syscall 2 ,
+.MR rt_sigqueueinfo 2 ,
+.MR setitimer 2 ,
+.MR setrlimit 2 ,
+.MR sgetmask 2 ,
+.MR sigaction 2 ,
+.MR sigaltstack 2 ,
+.MR signal 2 ,
+.MR signalfd 2 ,
+.MR sigpending 2 ,
+.MR sigprocmask 2 ,
+.MR sigreturn 2 ,
+.MR sigsuspend 2 ,
+.MR sigwaitinfo 2 ,
+.MR abort 3 ,
+.MR bsd_signal 3 ,
+.MR killpg 3 ,
+.MR longjmp 3 ,
+.MR pthread_sigqueue 3 ,
+.MR raise 3 ,
+.MR sigqueue 3 ,
+.MR sigset 3 ,
+.MR sigsetops 3 ,
+.MR sigvec 3 ,
+.MR sigwait 3 ,
+.MR strsignal 3 ,
+.MR swapcontext 3 ,
+.MR sysv_signal 3 ,
+.MR core 5 ,
+.MR proc 5 ,
+.MR nptl 7 ,
+.MR pthreads 7 ,
+.MR sigevent 3type