1.\" $OpenBSD: __thrsigdivert.2,v 1.5 2016/08/21 13:31:21 schwarze Exp $ 2.\" 3.\" Copyright (c) 2012 Philip Guenther <guenther@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: August 21 2016 $ 18.Dt __THRSIGDIVERT 2 19.Os 20.Sh NAME 21.Nm __thrsigdivert 22.Nd synchronously accept a signal 23.Sh SYNOPSIS 24.In sys/signal.h 25.In sys/time.h 26.Ft int 27.Fn __thrsigdivert "sigset_t set" "siginfo_t *info" "const struct timespec *timeout" 28.Sh DESCRIPTION 29The 30.Fn __thrsigdivert 31function is used to implement 32.Fn sigwait . 33It selects a signal pending for the calling thread or process from 34.Fa set , 35atomically clears it from that set of pending signals, 36and returns that signal number. 37If prior to the call to 38.Fn __thrsigdivert 39there are multiple pending instances of a single signal number, 40it is undefined whether upon successful return there are any remaining 41pending signals for that signal number. 42If no signal in 43.Fa set 44is pending at the time of the call, 45the thread shall be suspended until one or more becomes pending. 46The signals defined by 47.Fa set 48should have been blocked in all threads in the process at the time 49of the call to 50.Fn __thrsigdivert ; 51otherwise the signal may be delivered to some thread that does not 52have it blocked. 53.Pp 54If more than one thread is using 55.Fn __thrsigdivert 56to wait for the same signal, 57no more than one of these threads shall return from 58.Fn __thrsigdivert 59for any given signal that is sent. 60Which thread returns from 61.Fn __thrsigdivert 62if more than a single thread is waiting is unspecified. 63.Pp 64If the 65.Fa info 66argument is not 67.Dv NULL , 68then a 69.Vt siginfo_t 70will be stored there which has the selected signal number in its 71.Fa si_signo 72member and the cause of the signal in its 73.Fa si_code 74member. 75.Pp 76If the 77.Fa timeout 78argument is not 79.Dv NULL 80and no selected signal is currently pending, 81then 82.Fn __thrsigdivert 83will wait no longer than the specified time period for a signal to 84arrive before failing. 85.Sh RETURN VALUES 86If successful, 87the number of the signal that was accepted is returned. 88Otherwise, a value of -1 is returned and 89.Dv errno 90is set to indicate the error. 91.Sh ERRORS 92.Fn __thrsigdivert 93will succeed unless: 94.Bl -tag -width Er 95.It Bq Er EWOULDBLOCK 96The timeout was reached before a selected signal was received. 97.El 98.Sh SEE ALSO 99.Xr sigaction 2 , 100.Xr sigprocmask 2 , 101.Xr sigwait 3 102.Sh STANDARDS 103The 104.Fn __thrsigdivert 105function is specific to 106.Ox 107and should not be used in portable applications. 108.Sh HISTORY 109A 110.Fn thrsigdivert 111syscall appeared in 112.Ox 3.9 . 113The 114.Fa info 115and 116.Fa timeout 117arguments were added in 118.Ox 4.9 . 119.Sh AUTHORS 120.An -nosplit 121The 122.Fn thrsigdivert 123syscall was created by 124.An Ted Unangst Aq Mt tedu@OpenBSD.org . 125This manual page was written by 126.An Philip Guenther Aq Mt guenther@OpenBSD.org . 127