]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/sigwaitinfo.2
zfs: merge openzfs/zfs@8e8acabdc
[FreeBSD/FreeBSD.git] / lib / libc / sys / sigwaitinfo.2
1 .\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd April 21, 2022
31 .Dt SIGTIMEDWAIT 2
32 .Os
33 .Sh NAME
34 .Nm sigtimedwait , sigwaitinfo
35 .Nd "wait for queued signals (REALTIME)"
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .In signal.h
40 .Ft int
41 .Fo sigtimedwait
42 .Fa "const sigset_t *restrict set" "siginfo_t *restrict info"
43 .Fa "const struct timespec *restrict timeout"
44 .Fc
45 .Ft int
46 .Fn sigwaitinfo "const sigset_t * restrict set" "siginfo_t * restrict info"
47 .Sh DESCRIPTION
48 The
49 .Fn sigtimedwait
50 system call is equivalent to
51 .Fn sigwaitinfo
52 except that if none of the signals specified by
53 .Fa set
54 are pending,
55 .Fn sigtimedwait
56 waits for the time interval specified in the
57 .Vt timespec
58 structure referenced by
59 .Fa timeout .
60 If the
61 .Vt timespec
62 structure pointed to by
63 .Fa timeout
64 is zero-valued and if none of the signals specified by
65 .Fa set
66 are pending, then
67 .Fn sigtimedwait
68 returns immediately with an error.
69 If
70 .Fa timeout
71 is the
72 .Dv NULL
73 pointer,
74 .Fn sigtimedwait
75 blocks indefinitely.
76 .Dv CLOCK_MONOTONIC
77 clock is used to measure the time interval specified by the
78 .Fa timeout
79 argument.
80 .Pp
81 The
82 .Fn sigwaitinfo
83 system call selects the pending signal from the set specified by
84 .Fa set .
85 Should any of multiple pending signals in the range
86 .Dv SIGRTMIN
87 to
88 .Dv SIGRTMAX
89 be selected, it shall be the lowest numbered one.
90 The
91 selection order between realtime and non-realtime signals, or
92 between multiple pending non-realtime signals, is unspecified.
93 If no signal in
94 .Fa set
95 is pending at the time of the call, the calling thread
96 is suspended until one or more signals in
97 .Fa set
98 become pending or until it is interrupted by an unblocked, caught signal.
99 .Pp
100 The
101 .Fn sigwaitinfo
102 system call is equivalent to the
103 .Fn sigwait
104 system call if the
105 .Fa info
106 argument is
107 .Dv NULL .
108 If the
109 .Fa info
110 argument is
111 .Pf non- Dv NULL ,
112 the
113 .Fn sigwaitinfo
114 function is equivalent to
115 .Fn sigwait ,
116 except that the selected signal number shall be stored in the
117 .Va si_signo
118 member, and the cause of the signal shall be stored in the
119 .Va si_code
120 member.
121 Besides this, the
122 .Fn sigwaitinfo
123 and
124 .Fn sigtimedwait
125 system calls may return
126 .Er EINTR
127 if interrupted by signal, which is not allowed for the
128 .Fn sigwait
129 function.
130 .Pp
131 If any value is queued to the selected signal, the first such queued
132 value is dequeued and, if the info argument is
133 .Pf non- Dv NULL ,
134 the value is stored in the
135 .Va si_value
136 member of
137 .Fa info .
138 The system resource used to queue the signal
139 is released and returned to the system for other use.
140 If no value is queued,
141 the content of the
142 .Va si_value
143 member is zero-valued.
144 If no further signals are
145 queued for the selected signal, the pending indication for that signal
146 is reset.
147 .Sh RETURN VALUES
148 Upon successful completion (that is, one of the signals specified by
149 .Fa set
150 is pending or is generated)
151 .Fn sigwaitinfo
152 and
153 .Fn sigtimedwait
154 return the selected signal number.
155 Otherwise, the functions return a value of \-1
156 and set the global variable
157 .Va errno
158 to indicate the error.
159 .Sh ERRORS
160 The
161 .Fn sigtimedwait
162 system call
163 will fail if:
164 .Bl -tag -width Er
165 .It Bq Er EAGAIN
166 No signal specified by set was generated within the specified timeout period.
167 .El
168 .Pp
169 The
170 .Fn sigtimedwait
171 and
172 .Fn sigwaitinfo
173 system calls fail if:
174 .Bl -tag -width Er
175 .It Bq Er EINTR
176 The wait was interrupted by an unblocked, caught signal.
177 .El
178 .Pp
179 The
180 .Fn sigtimedwait
181 system call may also fail if:
182 .Bl -tag -width Er
183 .It Bq Er EINVAL
184 The
185 .Fa timeout
186 argument specified a
187 .Va tv_nsec
188 value less than zero or greater than or equal
189 to 1000 million.
190 Kernel only checks for this error if no signal is pending in set and it
191 is necessary to wait.
192 .El
193 .Sh SEE ALSO
194 .Xr sigaction 2 ,
195 .Xr sigpending 2 ,
196 .Xr sigqueue 2 ,
197 .Xr sigsuspend 2 ,
198 .Xr sigwait 2 ,
199 .Xr pause 3 ,
200 .Xr pthread_sigmask 3 ,
201 .Xr siginfo 3
202 .Sh STANDARDS
203 The
204 .Fn sigtimedwait
205 and
206 .Fn sigwaitinfo
207 system calls conform to
208 .St -p1003.1-96 .
209 POSIX
210 leaves the behavior of
211 .Fn sigtimedwait
212 with a
213 .Dv NULL
214 .Fa timeout
215 pointer unspecified.