Function rustix::event::select

source ·
pub unsafe fn select(
    nfds: i32,
    readfds: Option<&mut [FdSetElement]>,
    writefds: Option<&mut [FdSetElement]>,
    exceptfds: Option<&mut [FdSetElement]>,
    timeout: Option<&Timespec>,
) -> Result<i32>
Expand description

select(nfds, readfds, writefds, exceptfds, timeout)—Wait for events on sets of file descriptors.

readfds, writefds, exceptfds must point to arrays of FdSetElement containing at least nfds.div_ceil(size_of::<FdSetElement>()) elements.

This select wrapper differs from POSIX in that nfds is not limited to FD_SETSIZE. Instead of using the fixed-sized fd_set type, this function takes raw pointers to arrays of fd_set_num_elements(max_fd + 1, num_fds), where max_fd is the maximum value of any fd that will be inserted into the set, and num_fds is the maximum number of fds that will be inserted into the set.

In particular, on Apple platforms, this function behaves as if _DARWIN_UNLIMITED_SELECT were predefined.

On illumos, this function is not defined because the select function on this platform always has an FD_SETSIZE limitation, following POSIX. This platform’s documentation recommends using poll instead.

fd_set_insert, fd_set_remove, and FdSetIter are provided for setting, clearing, and iterating with sets.

§Safety

All fds in in all the sets must correspond to open file descriptors.

§References