1.\" $OpenBSD: sigwait.3,v 1.13 2003/05/18 13:06:33 jmc Exp $ 2.\" 3.\" David Leonard <d@openbsd.org>, 1998. Public domain. 4.Dd August 20, 1998 5.Dt SIGWAIT 3 6.Os 7.Sh NAME 8.Nm sigwait 9.Nd synchronously accept a signal 10.Sh SYNOPSIS 11.Fd #include <signal.h> 12.Ft int 13.Fn sigwait "const sigset_t *set" "int *sig" 14.Sh DESCRIPTION 15The 16.Fn sigwait 17function selects a pending signal from 18.Fa set , 19atomically clears it from the system's set of pending signals, and returns 20that signal number in the location referenced by 21.Fa sig . 22If prior to the call to 23.Fn sigwait 24there are multiple pending instances of a single signal number, 25it is undefined whether upon successful return there are any remaining pending 26signals for that signal number. 27If no signal in 28.Fa set 29is pending at the time of the call, 30the thread shall be suspended until one or more becomes pending. 31The signals defined by 32.Fa set 33should have been blocked at the time of the call to 34.Fn sigwait ; 35otherwise the behaviour is undefined. 36The effect of 37.Fn sigwait 38on the signal actions for the signals in 39.Fa set 40is unspecified. 41.Pp 42If more than one thread is using 43.Fn sigwait 44to wait for the same signal, 45no more than one of these threads shall return from 46.Fn sigwait 47with the signal number. 48Which thread returns from 49.Fn sigwait 50if more than a single thread is waiting is unspecified. 51.Pp 52.Sy Note : 53Code using the 54.Fn sigwait 55function must be compiled and linked with the 56.Cm -pthread 57option to 58.Xr gcc 1 . 59.Sh RETURN VALUES 60Upon successful completion, 61.Fn sigwait 62stores the signal number of the received signal at the location referenced by 63.Fa sig 64and returns zero. 65.Sh ERRORS 66On error, 67.Fn sigwait 68returns one of these error values: 69.Bl -tag -width Er 70.It Bq Er EINVAL 71The 72.Fa set 73argument contains an invalid or unsupported signal number. 74.El 75.Sh SEE ALSO 76.Xr sigaction 2 , 77.Xr sigpending 2 , 78.Xr sigsuspend 2 , 79.Xr pause 3 , 80.Xr pthread_sigmask 3 , 81.Xr pthreads 3 82.Sh STANDARDS 83.Fn sigwait 84conforms to 85.St -p1003.1-96 . 86