NetBSD/lib/libc/sys/sigtimedwait.2
jdolecek af3d346a8c add POSIX sigtimedwait(), sigwaitinfo(), sigwait() - wait for queued signals
note these are for non-threaded programs only - libpthread will provide
it's own thread-aware wrapper
2003-02-15 21:11:47 +00:00

158 lines
4.5 KiB
Groff

.\" $NetBSD: sigtimedwait.2,v 1.1 2003/02/15 21:11:49 jdolecek Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jaromir Dolecek.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 10, 2003
.Dt SIGTIMEDWAIT 2
.Os
.Sh NAME
.Nm sigtimedwait ,
.Nm sigwaitinfo ,
.Nm sigwait
.Nd wait for queued signals
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd #include \*[Lt]signal.h\*[Gt]
.Ft int
.Fn sigtimedwait "const sigset_t * restrict set" "siginfo_t * restrict info" "const struct timespec * restrict timeout"
.Ft int
.Fn sigwaitinfo "const sigset_t * restrict set" "siginfo_t * restrict info"
.Ft int
.Fn sigwait "const sigset_t * restrict set" "int * restrict sig"
.Sh DESCRIPTION
.Fn sigwaitinfo
and
.Fn sigwait
return first pending signal from the set specified by
.Fa set .
Should multiple signals from
.Fa set
be pending, the lowest numbered one is returned. The selection
order between realtime and non-realtime signals is unspecified.
If there is no signal from
.Ar set
pending at the time of the call, calling thread
is suspended until the signal would be generated.
.Pp
.Fn sigtimedwait
is exactly equal to
.Fn sigwaitinfo ,
except
.Fa timeout
specifies the maximum time interval it would suspend for.
If
.Fa timeout
is zero (tv_sec == tv_nsec == 0),
.Fn sigtimedwait
only checks current pending signals and returns immediatelly.
If
.Va NULL
is used for
.Fa timeout ,
.Fn sigtimedwait
is exactly equal to
.Fn sigwaitinfo
in all regards.
.Pp
If there are several threads waiting for given signal, exactly one of them
returns from the signal wait when the signal would be generated.
.Pp
Behaviour of these functions is unspecified if any of the signals
in
.Fa set
are unblocked at the time these functions are called.
.Sh RETURN VALUES
Upon successful completion
.Fa info
is updated with signal information, and function returns 0.
Otherwise, a \-1 is returned and the global variable
.Va errno
indicates the error.
.Sh ERRORS
.Fn sigwaitinfo
and
.Fn sigwait
always succeed.
.Pp
.Fn sigtimedwait
will fail and the
.Fa info
pointer will remain unchanged if:
.Bl -tag -width Er
.It Bq Er EAGAIN
No signal specified in
.Fa set
was generated in in specified
.Fa timeout .
.El
.Pp
.Fn sigtimedwait
may also fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The specified
.Fa timeout
was invalid.
.El
.Pp
This error is only checked if no signal from
.Fa set
is pending and it would be necessary to wait.
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr sigprocmask 2 ,
.Xr signal 7
.Sh STANDARDS
The functions
.Fn sigtimedwait ,
.Fn sigwaitinfo
and
.Fn sigwait
conform to
.St -p1003.1-2001 .
.Sh HISTORY
.Fn sigtimedwait ,
.Fn sigwaitinfo
and
.Fn sigwait
functions appeared in
.Nx 2.0 .
.Sh AUTHORS
The initial
.Nx
implementation of signal wait functions was written by
.An Jaromir Dolecek Aq jdolecek@NetBSD.org .