The select(2) system call is defined as follows in chapter 6.3 of Unix Network Programming (2003) by Stevens, Fenner and Rudoff:
#include <sys/select.h>
#include <sys/time.h>
int select(int maxfdp1, fd_set *readset, fd_set *writeset,
fd_set *exceptset, const struct timeval *timeout);
But none of modern Unixes such as FreeBSD, OpenBSD, NetBSD, Linux, and even the POSIX[1] standard, define the system call as such. However, it is noted in the book that "POSIX specifies the const qualifier". Is it an error in the book? Or, is it because of a historical reason? All systems define pselect(2) to have a constant timeout parameter, though.
http://pubs.opengroup.org/onlinepubs/009695399/functions/pselect.html
The book errata page does not list this as an error:
POSIX defines the interface to select()
as:
int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict errorfds, struct timeval *restrict timeout);
The select() function shall be equivalent to the pselect() function, except as follows:
- ...
- Upon successful completion, the select() function may modify the object pointed to by the timeout argument.
The pselect
function takes a const struct timespec * restrict timeout
argument (same page in the POSIX definition).
The const
qualifier quoted by the book is a mistake.