select(2) DG/UX 5.4 Rel. 2.01 select(2)
NAME
select - examine file descriptors for I/O readiness
SYNOPSIS
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
int select (maxfds, readfds, writefds, exceptfds, maxtime)
int maxfds;
fdset *readfds, *writefds, *exceptfds;
struct timeval*maxtime;
FDSET (fd, &fdset)
FDCLR (fd, &fdset)
FDISSET (fd, &fdset)
FDZERO (&fdset)
int fd;
fdset fdset;
DESCRIPTION
Use select(2) to find out whether specified file descriptors, stored
as bit fields in arrays of integers, are ready for processing. The
parameters are:
maxfds The maximum number of file descriptors allowed for the
calling process.
readfds A bitmask containing the addresses of file descriptors to
be examined for read readiness.
writefds A bitmask containing the addresses of file descriptors to
be examined for write readiness.
exceptfds A bitmask containing the addresses of file descriptors to
be examined for pending exception conditions.
maxtime The maximum interval of time to wait for the request to
complete.
Typically, maxfds is the value of GET_MAX_OPEN returned by ulimit(2);
select(2) examines up to (maxfds - 1) bits in each file descriptor
bitmask.
If maxtime is NULL, select(2) will wait indefinitely for the request
to complete. Otherwise, and should maxtime lapse before completion,
it returns 0 without modifying any descriptor bitmasks.
The bitmasks readfds, writefds, and exceptfds store file descriptors
as bits in arrays of 32-bit integers. On a successful completion,
select(2) returns the bitmasks in place, appropriately modified. You
can enter NULL in place of a bitmask you don't care about.
The following macros are provided for manipulating these bitmasks:
Licensed material--property of copyright holder(s) 1
select(2) DG/UX 5.4 Rel. 2.01 select(2)
FD_ZERO (&fdset) Initializes a bitmask fdset to null.
FD_SET (fd, &fdset)
Includes a descriptor fd in fdset.
FD_CLR (fd, &fdset)
Removes fd from fdset.
FD_ISSET (fd, &fdset)
Is nonzero if fd is a member of fdset, or zero
otherwise.
The behavior of these macros is undefined if a descriptor value is
less than zero or greater than or equal to FD_SETSIZE.
Under rare circumstances, select(2) may indicate that a descriptor is
ready for writing when in fact an attempt to write would block. This
can happen if system resources necessary for a write are exhausted or
otherwise unavailable. To guarantee that writes to a file descriptor
do not block, you can set the descriptor for non-blocking I/O: invoke
fcntl(2) with the F_SETFL command and O_NONBLOCK argument.
RETURN VALUE
1..3*maxfds
Completed successfully. The sum of the number of
descriptors identified in each bit mask is returned.
0 Time limit maxtime expired before completion.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to one of the following error codes:
EBADF One of the bit masks specified an invalid descriptor.
EFAULT One of the pointers given in the call referred to a
location that does not exist in the process's address
space.
EINTR A signal was delivered before any of the selected-for
events occurred and before the time limit expired.
EINVAL A component of the pointed-to time limit is outside the
acceptable range:
0 < t_sec < 10^8
0 < t_usec < 10^6.
SEE ALSO
accept(2), connect(2), fcntl(2) read(2), readv(2), recv(2), send(2),
ulimit(2), write(2), writev(2).
Licensed material--property of copyright holder(s) 2