xref: /freebsd/lib/libsys/sigwait.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2*8269e767SBrooks Davis.\" All rights reserved.
3*8269e767SBrooks Davis.\"
4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
6*8269e767SBrooks Davis.\" are met:
7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
8*8269e767SBrooks Davis.\"    notice(s), this list of conditions and the following disclaimer as
9*8269e767SBrooks Davis.\"    the first lines of this file unmodified other than the possible
10*8269e767SBrooks Davis.\"    addition of one or more copyright notices.
11*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
12*8269e767SBrooks Davis.\"    notice(s), this list of conditions and the following disclaimer in
13*8269e767SBrooks Davis.\"    the documentation and/or other materials provided with the
14*8269e767SBrooks Davis.\"    distribution.
15*8269e767SBrooks Davis.\"
16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17*8269e767SBrooks Davis.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*8269e767SBrooks Davis.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20*8269e767SBrooks Davis.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*8269e767SBrooks Davis.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*8269e767SBrooks Davis.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23*8269e767SBrooks Davis.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24*8269e767SBrooks Davis.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25*8269e767SBrooks Davis.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26*8269e767SBrooks Davis.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*8269e767SBrooks Davis.\"
28*8269e767SBrooks Davis.Dd September 6, 2013
29*8269e767SBrooks Davis.Dt SIGWAIT 2
30*8269e767SBrooks Davis.Os
31*8269e767SBrooks Davis.Sh NAME
32*8269e767SBrooks Davis.Nm sigwait
33*8269e767SBrooks Davis.Nd select a set of signals
34*8269e767SBrooks Davis.Sh LIBRARY
35*8269e767SBrooks Davis.Lb libc
36*8269e767SBrooks Davis.Sh SYNOPSIS
37*8269e767SBrooks Davis.In signal.h
38*8269e767SBrooks Davis.Ft int
39*8269e767SBrooks Davis.Fn sigwait "const sigset_t * restrict set" "int * restrict sig"
40*8269e767SBrooks Davis.Sh DESCRIPTION
41*8269e767SBrooks DavisThe
42*8269e767SBrooks Davis.Fn sigwait
43*8269e767SBrooks Davissystem call selects a set of signals, specified by
44*8269e767SBrooks Davis.Fa set .
45*8269e767SBrooks DavisIf none of the selected signals are pending,
46*8269e767SBrooks Davis.Fn sigwait
47*8269e767SBrooks Daviswaits until one or more of the selected signals has been generated.
48*8269e767SBrooks DavisThen
49*8269e767SBrooks Davis.Fn sigwait
50*8269e767SBrooks Davisatomically clears one of the selected signals from the set of pending signals
51*8269e767SBrooks Davis(for the process or for the current thread) and sets the location pointed to by
52*8269e767SBrooks Davis.Fa sig
53*8269e767SBrooks Davisto the signal number that was cleared.
54*8269e767SBrooks Davis.Pp
55*8269e767SBrooks DavisThe signals specified by
56*8269e767SBrooks Davis.Fa set
57*8269e767SBrooks Davisshould be blocked at the time of the call to
58*8269e767SBrooks Davis.Fn sigwait .
59*8269e767SBrooks Davis.Pp
60*8269e767SBrooks DavisIf more than one thread is using
61*8269e767SBrooks Davis.Fn sigwait
62*8269e767SBrooks Davisto wait for the same signal, no more than one of these threads will return from
63*8269e767SBrooks Davis.Fn sigwait
64*8269e767SBrooks Daviswith the signal number.
65*8269e767SBrooks DavisIf more than a single thread is blocked in
66*8269e767SBrooks Davis.Fn sigwait
67*8269e767SBrooks Davisfor a signal when that signal is generated for the process, it is unspecified
68*8269e767SBrooks Daviswhich of the waiting threads returns from
69*8269e767SBrooks Davis.Fn sigwait .
70*8269e767SBrooks DavisIf the signal is generated for a specific thread, as by
71*8269e767SBrooks Davis.Fn pthread_kill ,
72*8269e767SBrooks Davisonly that thread will return.
73*8269e767SBrooks Davis.Pp
74*8269e767SBrooks DavisShould any of the multiple pending signals in the range
75*8269e767SBrooks Davis.Dv SIGRTMIN
76*8269e767SBrooks Davisto
77*8269e767SBrooks Davis.Dv SIGRTMAX
78*8269e767SBrooks Davisbe
79*8269e767SBrooks Davisselected, it will be the lowest numbered one.
80*8269e767SBrooks DavisThe selection order between realtime
81*8269e767SBrooks Davisand non-realtime signals, or between multiple pending non-realtime signals,
82*8269e767SBrooks Davisis unspecified.
83*8269e767SBrooks Davis.Sh IMPLEMENTATION NOTES
84*8269e767SBrooks DavisThe
85*8269e767SBrooks Davis.Fn sigwait
86*8269e767SBrooks Davisfunction is implemented as a wrapper around the
87*8269e767SBrooks Davis.Fn __sys_sigwait
88*8269e767SBrooks Davissystem call, which retries the call on
89*8269e767SBrooks Davis.Er EINTR
90*8269e767SBrooks Daviserror.
91*8269e767SBrooks Davis.Sh RETURN VALUES
92*8269e767SBrooks DavisIf successful,
93*8269e767SBrooks Davis.Fn sigwait
94*8269e767SBrooks Davisreturns 0 and sets the location pointed to by
95*8269e767SBrooks Davis.Fa sig
96*8269e767SBrooks Davisto the cleared signal number.
97*8269e767SBrooks DavisOtherwise, an error number is returned.
98*8269e767SBrooks Davis.Sh ERRORS
99*8269e767SBrooks DavisThe
100*8269e767SBrooks Davis.Fn sigwait
101*8269e767SBrooks Davissystem call will fail if:
102*8269e767SBrooks Davis.Bl -tag -width Er
103*8269e767SBrooks Davis.It Bq Er EINVAL
104*8269e767SBrooks DavisThe
105*8269e767SBrooks Davis.Fa set
106*8269e767SBrooks Davisargument
107*8269e767SBrooks Davisspecifies one or more invalid signal numbers.
108*8269e767SBrooks Davis.El
109*8269e767SBrooks Davis.Sh SEE ALSO
110*8269e767SBrooks Davis.Xr sigaction 2 ,
111*8269e767SBrooks Davis.Xr sigpending 2 ,
112*8269e767SBrooks Davis.Xr sigqueue 2 ,
113*8269e767SBrooks Davis.Xr sigsuspend 2 ,
114*8269e767SBrooks Davis.Xr sigtimedwait 2 ,
115*8269e767SBrooks Davis.Xr sigwaitinfo 2 ,
116*8269e767SBrooks Davis.Xr pause 3 ,
117*8269e767SBrooks Davis.Xr pthread_sigmask 3
118*8269e767SBrooks Davis.Sh STANDARDS
119*8269e767SBrooks DavisThe
120*8269e767SBrooks Davis.Fn sigwait
121*8269e767SBrooks Davisfunction conforms to
122*8269e767SBrooks Davis.St -p1003.1-96 .
123