Update some signal man pages for multithreading.

This commit is contained in:
Jilles Tjoelker 2013-09-06 09:08:40 +00:00
parent 4758b87596
commit 75b1cda430
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=255296
4 changed files with 41 additions and 25 deletions

View File

@ -28,7 +28,7 @@
.\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94 .\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd June 8, 2013 .Dd September 6, 2013
.Dt SIGACTION 2 .Dt SIGACTION 2
.Os .Os
.Sh NAME .Sh NAME
@ -55,7 +55,7 @@ struct sigaction {
.Sh DESCRIPTION .Sh DESCRIPTION
The system defines a set of signals that may be delivered to a process. The system defines a set of signals that may be delivered to a process.
Signal delivery resembles the occurrence of a hardware interrupt: Signal delivery resembles the occurrence of a hardware interrupt:
the signal is normally blocked from further occurrence, the current process the signal is normally blocked from further occurrence, the current thread
context is saved, and a new one is built. context is saved, and a new one is built.
A process may specify a A process may specify a
.Em handler .Em handler
@ -64,13 +64,14 @@ to which a signal is delivered, or specify that a signal is to be
A process may also specify that a default action is to be taken A process may also specify that a default action is to be taken
by the system when a signal occurs. by the system when a signal occurs.
A signal may also be A signal may also be
.Em blocked , .Em blocked
in which case its delivery is postponed until it is for a thread,
in which case it will not be delivered to that thread until it is
.Em unblocked . .Em unblocked .
The action to be taken on delivery is determined at the time The action to be taken on delivery is determined at the time
of delivery. of delivery.
Normally, signal handlers execute on the current stack Normally, signal handlers execute on the current stack
of the process. of the thread.
This may be changed, on a per-handler basis, This may be changed, on a per-handler basis,
so that signals are taken on a special so that signals are taken on a special
.Em "signal stack" . .Em "signal stack" .
@ -82,20 +83,30 @@ but other signals may yet occur.
A global A global
.Em "signal mask" .Em "signal mask"
defines the set of signals currently blocked from delivery defines the set of signals currently blocked from delivery
to a process. to a thread.
The signal mask for a process is initialized The signal mask for a thread is initialized
from that of its parent (normally empty). from that of its parent (normally empty).
It may be changed with a It may be changed with a
.Xr sigprocmask 2 .Xr sigprocmask 2
call, or when a signal is delivered to the process. or
.Xr pthread_sigmask 3
call, or when a signal is delivered to the thread.
.Pp .Pp
When a signal When a signal
condition arises for a process, the signal is added to a set of condition arises for a process or thread, the signal is added to a set of
signals pending for the process. signals pending for the process or thread.
If the signal is not currently Whether the signal is directed at the process in general or at a specific
thread depends on how it is generated.
For signals directed at a specific thread,
if the signal is not currently
.Em blocked .Em blocked
by the process then it is delivered to the process. by the thread then it is delivered to the thread.
Signals may be delivered any time a process enters the operating system For signals directed at the process,
if the signal is not currently
.Em blocked
by all threads then it is delivered to one thread that does not have it blocked
(the selection of which is unspecified).
Signals may be delivered any time a thread enters the operating system
(e.g., during a system call, page fault or trap, or clock interrupt). (e.g., during a system call, page fault or trap, or clock interrupt).
If multiple signals are ready to be delivered at the same time, If multiple signals are ready to be delivered at the same time,
any signals that could be caused by traps are delivered first. any signals that could be caused by traps are delivered first.
@ -106,17 +117,17 @@ The set of pending signals is returned by the
.Xr sigpending 2 .Xr sigpending 2
system call. system call.
When a caught signal When a caught signal
is delivered, the current state of the process is saved, is delivered, the current state of the thread is saved,
a new signal mask is calculated (as described below), a new signal mask is calculated (as described below),
and the signal handler is invoked. and the signal handler is invoked.
The call to the handler The call to the handler
is arranged so that if the signal handling routine returns is arranged so that if the signal handling routine returns
normally the process will resume execution in the context normally the thread will resume execution in the context
from before the signal's delivery. from before the signal's delivery.
If the process wishes to resume in a different context, then it If the thread wishes to resume in a different context, then it
must arrange to restore the previous context itself. must arrange to restore the previous context itself.
.Pp .Pp
When a signal is delivered to a process a new signal mask is When a signal is delivered to a thread a new signal mask is
installed for the duration of the process' signal handler installed for the duration of the process' signal handler
(or until a (or until a
.Xr sigprocmask 2 .Xr sigprocmask 2
@ -218,7 +229,7 @@ to
If this bit is set, the system will deliver the signal to the process If this bit is set, the system will deliver the signal to the process
on a on a
.Em "signal stack" , .Em "signal stack" ,
specified with specified by each thread with
.Xr sigaltstack 2 . .Xr sigaltstack 2 .
.It Dv SA_NODEFER .It Dv SA_NODEFER
If this bit is set, further occurrences of the delivered signal are If this bit is set, further occurrences of the delivered signal are
@ -272,6 +283,11 @@ However, calls that have already committed are not restarted,
but instead return a partial success (for example, a short read count). but instead return a partial success (for example, a short read count).
.Pp .Pp
After a After a
.Xr pthread_create 3
the signal mask is inherited by the new thread and
the set of pending signals and the signal stack for the new thread are empty.
.Pp
After a
.Xr fork 2 .Xr fork 2
or or
.Xr vfork 2 .Xr vfork 2

View File

@ -31,7 +31,7 @@
.\" @(#)sigpending.2 8.3 (Berkeley) 1/12/94 .\" @(#)sigpending.2 8.3 (Berkeley) 1/12/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd January 12, 1994 .Dd September 6, 2013
.Dt SIGPENDING 2 .Dt SIGPENDING 2
.Os .Os
.Sh NAME .Sh NAME
@ -47,7 +47,7 @@
The The
.Fn sigpending .Fn sigpending
system call returns a mask of the signals pending for delivery system call returns a mask of the signals pending for delivery
to the calling process in the location indicated by to the calling thread or the calling process in the location indicated by
.Fa set . .Fa set .
Signals may be pending because they are currently masked, Signals may be pending because they are currently masked,
or transiently before delivery (although the latter case is not or transiently before delivery (although the latter case is not

View File

@ -28,7 +28,7 @@
.\" @(#)sigreturn.2 8.1 (Berkeley) 6/4/93 .\" @(#)sigreturn.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd June 4, 1993 .Dd September 6, 2013
.Dt SIGRETURN 2 .Dt SIGRETURN 2
.Os .Os
.Sh NAME .Sh NAME
@ -46,7 +46,7 @@ The
system call system call
allows users to atomically unmask, switch stacks, allows users to atomically unmask, switch stacks,
and return from a signal context. and return from a signal context.
The processes signal mask and stack status are The thread's signal mask and stack status are
restored from the context structure pointed to by restored from the context structure pointed to by
.Fa scp . .Fa scp .
The system call does not return; The system call does not return;
@ -65,7 +65,7 @@ is set to indicate the error.
The The
.Fn sigreturn .Fn sigreturn
system call system call
will fail and the process context will remain unchanged will fail and the thread context will remain unchanged
if one of the following occurs. if one of the following occurs.
.Bl -tag -width Er .Bl -tag -width Er
.It Bq Er EFAULT .It Bq Er EFAULT

View File

@ -27,7 +27,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 27, 2012 .Dd September 6, 2013
.Dt SIGWAIT 2 .Dt SIGWAIT 2
.Os .Os
.Sh NAME .Sh NAME
@ -50,7 +50,7 @@ waits until one or more of the selected signals has been generated.
Then Then
.Fn sigwait .Fn sigwait
atomically clears one of the selected signals from the set of pending signals atomically clears one of the selected signals from the set of pending signals
for the process and sets the location pointed to by (for the process or for the current thread) and sets the location pointed to by
.Fa sig .Fa sig
to the signal number that was cleared. to the signal number that was cleared.
.Pp .Pp