Hash :
9500a55f
Author :
Date :
2012-10-02T15:29:13
select: reject invalid file descriptors POSIX requires invalid file descriptors to be detected rather than silently ignored. FreeBSD 8.2 detects if fd 0 has been closed and appears in a set while fd 1 is still open, but mistakenly optimizes and refuses to check any fds in the set beyond the maximum open fd. * m4/select.m4 (gl_FUNC_SELECT): Probe for FreeBSD bug. * lib/select.c (rpl_select) [!win32]: Work around it. * modules/select (Depends-on): Add dup2. * doc/posix-functions/select.texi (select): Document this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
@node select
@section @code{select}
@findex select
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/select.html}
Gnulib module: select
Portability problems fixed by Gnulib:
@itemize
@item
On Windows platforms (excluding Cygwin), @code{select} can only be
called on descriptors created by the @code{socket} function, not on regular
file descriptors.
@item
On Windows platforms (excluding Cygwin), error codes for @code{accept} are not
placed in @code{errno}, and @code{WSAGetLastError} must be used instead.
@item
This function fails when the @code{nfds} argument is 0 on some platforms:
Interix 3.5.
@item
On some platforms, this function fails to detect invalid fds with
EBADF, but only if they lie beyond the current maximum open fd:
FreeBSD 8.2.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
When you call @code{select} with a timeout, some implementations modify the
timeout parameter so that upon return from the function, it contains the
amount of time not slept. Other implementations leave the timeout parameter
unmodified.
@item
On BeOS, @code{select} can only be called on descriptors created by the
@code{socket} function, not on regular file descriptors.
@item
Under Windows, when passing a pipe, Gnulib's @code{select} replacement might
return 0 even before the timeout has passed. Programs using it with pipes can
thus busy wait.
@item
On Solaris 2.6 and older, @code{select} applied to a file descriptor opened
for reading and associated with @code{/dev/null} hangs, waiting for input,
when instead it should return immediately.
@item
On Linux, when some file descriptor refers to a regular file, @code{select}
may fail, setting @code{errno} to @code{EBADF}.
@item
This function is declared in @code{<unistd.h>}, not @code{<sys/select.h>},
on some platforms:
IRIX 5.3.
@end itemize