is select() being misused by the majority of programmers?

I've come across something that doesn't make much sense to me. The
standard Linux manpage for select() defines the first parameter as the
"maximum file descriptor in the set, plus one"...This never made any sense
to me because it would cause one to assume that all file descriptors in a
contiguous range will be polled, and thus negates the need for even
filling a descriptor set prior to calling select.

I've since found other documentation stating that in select(n,&inset...) n
is really the number of entries in the set inset. This makes much more
sense from a programmatic point of view. We're not going to be concerned
with a contiguous range of descriptors, but only the ones that were
explicitly set before calling select. Passing the length of the set makes
infinitely more sense.

All the programmers and examples I've seen use the first (and more likely
incorrect) semantics for the select() parameter.

What follows is from manpages found on my system that seems to back up my

pselect, select - synchronous I/O multiplexing

#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);

The pselect() function shall examine the file descriptor sets whose addresses are passed in
the readfds, writefds, and errorfds parameters to see whether some of their descriptors are
ready for reading, are ready for writing, or have an exceptional condition pending, respec-

The select() function shall be equivalent to the pselect() function, except as follows:

* For the select() function, the timeout period is given in seconds and microseconds in an
argument of type struct timeval, whereas for the pselect() function the timeout period is
given in seconds and nanoseconds in an argument of type struct timespec.

* The select() function has no sigmask argument; it shall behave as pselect() does when
sigmask is a null pointer.

* Upon successful completion, the select() function may modify the object pointed to by the
timeout argument.

The pselect() and select() functions shall support regular files, terminal and pseudo-termi-
nal devices, STREAMS-based files, FIFOs, pipes, and sockets. The behavior of pselect() and
select() on file descriptors that refer to other types of file is unspecified.

The nfds argument specifies the range of descriptors to be tested. The first nfds descrip-
tors shall be checked in each set; that is, the descriptors from zero through nfds-1 in the
descriptor sets shall be examined.

If the readfds argument is not a null pointer, it points to an object of type fd_set that on
input specifies the file descriptors to be checked for being ready to read, and on output
indicates which file descriptors are ready to read.


So, which is correct, and why?