xref: /netbsd-src/lib/libc/sys/sigtimedwait.2 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\" $NetBSD: sigtimedwait.2,v 1.3 2003/04/16 13:34:57 wiz Exp $
2.\"
3.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jaromir Dolecek.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd February 10, 2003
38.Dt SIGTIMEDWAIT 2
39.Os
40.Sh NAME
41.Nm sigtimedwait ,
42.Nm sigwaitinfo ,
43.Nm sigwait
44.Nd wait for queued signals
45.Sh LIBRARY
46.Lb libc
47.Sh SYNOPSIS
48.In signal.h
49.Ft int
50.Fn sigtimedwait "const sigset_t * restrict set" "siginfo_t * restrict info" "const struct timespec * restrict timeout"
51.Ft int
52.Fn sigwaitinfo "const sigset_t * restrict set" "siginfo_t * restrict info"
53.Ft int
54.Fn sigwait "const sigset_t * restrict set" "int * restrict sig"
55.Sh DESCRIPTION
56.Fn sigwaitinfo
57and
58.Fn sigwait
59return the first pending signal from the set specified by
60.Fa set .
61Should multiple signals from
62.Fa set
63be pending, the lowest numbered one is returned.
64The selection order between realtime and non-realtime signals is unspecified.
65If there is no signal from
66.Ar set
67pending at the time of the call, the calling thread
68is suspended until one of the specified signals is generated.
69.Pp
70.Fn sigtimedwait
71is exactly equal to
72.Fn sigwaitinfo ,
73except
74.Fa timeout
75specifies the maximum time interval for which the calling thread will
76be suspended.
77If
78.Fa timeout
79is zero (tv_sec == tv_nsec == 0),
80.Fn sigtimedwait
81only checks the currently pending signals and returns immediately.
82If
83.Dv NULL
84is used for
85.Fa timeout ,
86.Fn sigtimedwait
87behaves exactly like
88.Fn sigwaitinfo
89in all regards.
90.Pp
91If several threads are waiting for a given signal, exactly one of them
92returns from the signal wait when the signal is generated.
93.Pp
94Behaviour of these functions is unspecified if any of the signals in
95.Fa set
96are unblocked at the time these functions are called.
97.Sh RETURN VALUES
98Upon successful completion
99.Fa info
100is updated with signal information, and the function returns 0.
101Otherwise, \-1 is returned and the global variable
102.Va errno
103indicates the error.
104.Sh ERRORS
105.Fn sigwaitinfo
106and
107.Fn sigwait
108always succeed.
109.Pp
110.Fn sigtimedwait
111will fail and the
112.Fa info
113pointer will remain unchanged if:
114.Bl -tag -width Er
115.It Bq Er EAGAIN
116No signal specified in
117.Fa set
118was generated in the specified
119.Fa timeout .
120.El
121.Pp
122.Fn sigtimedwait
123may also fail if:
124.Bl -tag -width Er
125.It Bq Er EINVAL
126The specified
127.Fa timeout
128was invalid.
129.El
130.Pp
131This error is only checked if no signal from
132.Fa set
133is pending and it would be necessary to wait.
134.Sh SEE ALSO
135.Xr sigaction 2 ,
136.Xr sigprocmask 2 ,
137.Xr signal 7
138.Sh STANDARDS
139The functions
140.Fn sigtimedwait ,
141.Fn sigwaitinfo ,
142and
143.Fn sigwait
144conform to
145.St -p1003.1-2001 .
146.Sh HISTORY
147The
148.Fn sigtimedwait ,
149.Fn sigwaitinfo ,
150and
151.Fn sigwait
152functions appeared in
153.Nx 2.0 .
154.Sh AUTHORS
155The initial
156.Nx
157implementation of the signal wait functions was written by
158.An Jaromir Dolecek
159.Aq jdolecek@NetBSD.org .
160