c - select() with const timeout parameter? -


the select(2) system call defined follows in chapter 6.3 of unix network programming (2003) stevens, fenner , 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 freebsd, openbsd, netbsd, linux, , posix[1] standard, define system call such. however, noted in book "posix specifies const qualifier". error in book? or, because of historical reason? systems define pselect(2) have constant timeout parameter, though.

http://pubs.opengroup.org/onlinepubs/009695399/functions/pselect.html

the book errata page not list error:

http://www.unixnetworkprogramming.com/errata.html

posix defines interface 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 equivalent pselect() function, except follows:

  • ...
  • upon successful completion, select() function may modify object pointed timeout argument.

the pselect function takes const struct timespec * restrict timeout argument (same page in posix definition).

the const qualifier quoted book mistake.


Popular posts from this blog