select.2 (2012 03)
s
select(2) select(2)
NAME
select(), pselect(), FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO() - synchronous I/O multiplexing
SYNOPSIS
For UNIX 2003:
#include <sys/select.h>
int pselect(int nfds, fd_set *__restrict readfds,
fd_set *__restrict writefds, fd_set *__restrict errorfds,
const struct timespec *__restrict timeout,
const sigset_t *__restrict sigmask);
int select(int nfds, fd_set *__restrict readfds,
fd_set *__restrict writefds, fd_set *__restrict errorfds
struct timeval *__restrict timeout);
void FD_CLR(int fd, fd_set *fdset);
int FD_ISSET(int fd, fd_set *fdset);
void FD_SET(int fd, fd_set *fdset);
void FD_ZERO(fd_set *fdset);
For Standards prior to UNIX 2003:
#include <sys/time.h>
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *errorfds, struct timeval *timeout);
void FD_CLR(int fd, fd_set *fdset);
int FD_ISSET(int fd, fd_set *fdset);
void FD_SET(int fd, fd_set *fdset);
void FD_ZERO(fd_set *fdset);
For Backward Compatibility Only: (_XOPEN_SOURCE_EXTENDED not defined)
#include <time.h>
int select(size_t nfds, int *readfds, int *writefds,
int *exceptds, const struct timeval *timeout);
DESCRIPTION
Prototypes for select(), FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO(), are available by includ-
ing <sys/time.h> as required by standards prior to UNIX 2003. The UNIX 2003 standard requires
including <sys/select.h> to expose these prototypes along with pselect(). Refer to the stan-
dards(5) man page for information on how to compile programs by using the correct namespace for
different UNIX standards.
The
pselect() and select() functions indicate which of the specified file descriptors is ready for
reading, ready for writing, or has an error condition pending. If the specified condition is false for all of
the specified file descriptors, pselect() and select() block, up to the specified timeout interval,
until the specified condition is true for at least one of the specified file descriptors.
The
pselect() and select() functions support regular files, terminal and pseudo-terminal devices,
STREAMS-based files, FIFOs and pipes. The behaviour of pselect() and select() on file descrip-
tors that refer to other file types is unspecified.
The nfds argument specifies the range of file descriptors to be tested. The
pselect() and select()
functions test file descriptors in the range of 0 to nfds −1. File descriptor f is represented by the bit 1<<f
in the masks. More formally, a file descriptor is represented by:
fds[(f / BITS_PER_INT)] & (1 << (f % BITS_PER_INT))
HP-UX 11i Version 3: March 2012 − 1 − Hewlett-Packard Company 1