PSELECT(2)

πŸ’– PSELECT(2) πŸ’–

okay bestie, gather round, because today we're talking about pselect β€” the system call that does synchronous I/O multiplexing a la POSIX.1g ✨ she's giving select(2) but with a glow-up, and honestly? we're obsessed. this lives in section 2 of the System Calls Manual, so you know it's the real deal πŸ‘‘


🌸 NAME 🌸

pselect β€” synchronous I/O multiplexing a la POSIX.1g πŸ’…


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) 🫢


✨ SYNOPSIS ✨

#include <sys/select.h>

int
pselect(int nfds, fd_set * restrict readfds, fd_set * restrict writefds,
    fd_set * restrict exceptfds,
    const struct timespec * restrict timeout,
    const sigset_t * restrict newsigmask);

πŸ’œ DESCRIPTION πŸ’œ

so the tea is: pselect() was introduced by IEEE Std 1003.1g-2000 ("POSIX.1") as a slightly stronger version of select(2). like, select but she went to the gym πŸ’ͺ

the nfds, readfds, writefds, and exceptfds arguments are all identical to the analogous arguments of select(). no notes, same energy πŸ’―

the timeout argument in pselect() points to a const struct timespec rather than the (modifiable) struct timeval used by select(). and just like in select(), a null pointer may be passed to indicate that pselect() should wait indefinitely β€” girl will wait forever, no cap 😭

finally, newsigmask specifies a signal mask which is set while waiting for input. and when pselect() returns, the original signal mask is restored. she always puts things back where she found them, queen behavior πŸ‘‘

head over to select(2) for a more detailed discussion of the semantics of this interface, and for the macros used to manipulate the fd_set data type πŸ¦‹

πŸŽ€ RETURN VALUES πŸŽ€

the pselect() function returns the same values and under the same conditions as select(). that's it, that's the whole vibe ✨


πŸ’€ ERRORS πŸ’€

the pselect() function may fail for any of the reasons documented for select(2) and (if a signal mask is provided) sigprocmask(2). so like, check both receipts bestie πŸ™ˆ


🌈 SEE ALSO 🌈


⭐ STANDARDS ⭐

the pselect() function conforms to IEEE Std 1003.1-2001 ("POSIX.1"). certified, licensed, iconic πŸ’…


πŸ•°οΈ HISTORY πŸ•°οΈ

the pselect() function first appeared in FreeBSD 5.0. a legend was born ✨


🫢 AUTHORS 🫢

the first implementation of pselect() function and this manual page were written by Garrett Wollman <wollman@FreeBSD.org> πŸŽ€


and that's the whole page bestie!! this lil beauty is from the Debian crew, dated August 16, 2013, and yeah she's still rocking the PSELECT(2) title like the main character she is πŸ‘‘πŸ’– mwah, go multiplex something πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from