Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ select(2) — DG/UX 5.4R3.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

connect(2)

fcntl(2)

read(2)

readv(2)

recv(2)

send(2)

ulimit(2)

write(2)

writev(2)



select(2)                      DG/UX 5.4R3.00                      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;

   where:
       maxfds    The maximum number of file descriptors allowed for the
                 calling process.

       readfds   A bit mask containing the addresses of file descriptors to
                 be examined for read readiness.

       writefds  A bit mask containing the addresses of file descriptors to
                 be examined for write readiness.

       exceptfds A bit mask 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.

       fd        A file descriptor being examined

       fdset     A bit mask (file descriptor set)

DESCRIPTION
       Use select(2) to find out whether specified file descriptors, stored
       as bit fields in arrays of integers, are ready for processing.

       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
       bit mask.

       If maxtime is NULL, select(2) will wait indefinitely for the request
       to complete.  Otherwise, and should maxtime lapse before completion,
       it returns 0.  The descriptor sets are always modified on return,
       even if the call returns as the result of a timeout.

       The bit masks readfds, writefds, and exceptfds store file descriptors



Licensed material--property of copyright holder(s)                         1




select(2)                      DG/UX 5.4R3.00                      select(2)


       as bits in arrays of 32-bit integers.  On a successful completion,
       select(2) returns the bit masks in place, appropriately modified.
       You can enter NULL in place of a bit mask you don't care about.

       The following macros are provided for manipulating these bit masks:

       FDZERO (&fdset)      Initializes a bit mask fdset to null.

       FDSET (fd, &fdset)   Includes a descriptor fd in fdset.

       FDCLR (fd, &fdset)   Removes fd from fdset.

       FDISSET (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 < tsec < 10^8
                           0 < tusec < 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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026