1.\" 2.\" Copyright 2002 Massachusetts Institute of Technology 3.\" 4.\" Permission to use, copy, modify, and distribute this software and 5.\" its documentation for any purpose and without fee is hereby 6.\" granted, provided that both the above copyright notice and this 7.\" permission notice appear in all copies, that both the above 8.\" copyright notice and this permission notice appear in all 9.\" supporting documentation, and that the name of M.I.T. not be used 10.\" in advertising or publicity pertaining to distribution of the 11.\" software without specific, written prior permission. M.I.T. makes 12.\" no representations about the suitability of this software for any 13.\" purpose. It is provided "as is" without express or implied 14.\" warranty. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 17.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 20.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd December 24, 2007 30.Dt PSELECT 2 31.Os 32.Sh NAME 33.Nm pselect 34.Nd synchronous I/O multiplexing a la POSIX.1g 35.Sh LIBRARY 36.Lb libc 37.Sh SYNOPSIS 38.In sys/select.h 39.Ft int 40.Fo pselect 41.Fa "int nfds" 42.Fa "fd_set * restrict readfds" 43.Fa "fd_set * restrict writefds" 44.Fa "fd_set * restrict exceptfds" 45.Fa "const struct timespec * restrict timeout" 46.Fa "const sigset_t * restrict newsigmask" 47.Fc 48.Sh DESCRIPTION 49The 50.Fn pselect 51function was introduced by 52.St -p1003.1g-2000 53as a slightly stronger version of 54.Xr select 2 . 55The 56.Fa nfds , readfds , writefds , 57and 58.Fa exceptfds 59arguments are all identical to the analogous arguments of 60.Fn select . 61The 62.Fa timeout 63argument in 64.Fn pselect 65points to a 66.Vt "const struct timespec" 67rather than the (modifiable) 68.Vt "struct timeval" 69used by 70.Fn select ; 71as in 72.Fn select , 73a null pointer may be passed to indicate that 74.Fn pselect 75should wait indefinitely. 76Finally, 77.Fa newsigmask 78specifies a signal mask which is set while waiting for input. 79When 80.Fn pselect 81returns, the original signal mask is restored. 82.Pp 83See 84.Xr select 2 85for a more detailed discussion of the semantics of this interface, and 86for macros used to manipulate the 87.Vt "fd_set" 88data type. 89.Sh RETURN VALUES 90The 91.Fn pselect 92function returns the same values and under the same conditions as 93.Fn select . 94.Sh ERRORS 95The 96.Fn pselect 97function may fail for any of the reasons documented for 98.Xr select 2 99and (if a signal mask is provided) 100.Xr sigprocmask 2 . 101.Sh SEE ALSO 102.Xr kqueue 2 , 103.Xr poll 2 , 104.Xr select 2 , 105.Xr sigprocmask 2 106.Sh STANDARDS 107The 108.Fn pselect 109function conforms to 110.St -p1003.1-2001 . 111.Sh HISTORY 112The 113.Fn pselect 114function first appeared in 115.Dx 1.11 . 116.Sh AUTHORS 117This manual page was originally written by 118.An Garrett Wollman Aq Mt wollman@FreeBSD.org 119for 120.Fx 121and later modified for 122.Dx . 123.Sh BUGS 124The 125.Fn pselect 126implementation in libc_r (user multi-threading) does not mask signals, calls 127.Fn select , 128and restores the original signal mask atomically. A calling user thread 129using 130.Fn pselect 131to block until either a signal occurs or some descriptor changes may therefore 132block forever. 133The 134.Fn pselect 135implementations in libthread_xu (kernel multi-threading) and libc 136(single-threading) operate atomically and are therefore race-free. 137