1.\" $OpenBSD: sigwait.3,v 1.2 2019/01/13 16:16:43 jca Exp $ 2.\" 3.\" David Leonard <d@openbsd.org>, 1998. Public domain. 4.Dd $Mdocdate: January 13 2019 $ 5.Dt SIGWAIT 3 6.Os 7.Sh NAME 8.Nm sigwait 9.Nd synchronously accept a signal 10.Sh SYNOPSIS 11.In 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.Sh RETURN VALUES 52Upon successful completion, 53.Fn sigwait 54stores the signal number of the received signal at the location referenced by 55.Fa sig 56and returns zero. 57.Sh ERRORS 58On error, 59.Fn sigwait 60returns one of these error values: 61.Bl -tag -width Er 62.It Bq Er EINVAL 63The 64.Fa set 65argument contains an invalid or unsupported signal number. 66.El 67.Sh SEE ALSO 68.Xr sigaction 2 , 69.Xr sigpending 2 , 70.Xr sigsuspend 2 , 71.Xr pause 3 , 72.Xr pthread_sigmask 3 73.Sh STANDARDS 74.Fn sigwait 75conforms to 76.St -p1003.1-96 . 77