[PATCH] manual: Adjust documentation to standardization of select
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Aug 4 14:18:10 GMT 2025
On 26/07/25 01:15, Collin Funk wrote:
> The select function, fd_set, and FD_* macros were standardized by POSIX
> in the sys/select.h header. They are still defined in sys/types.h if
> __USE_MISC is defined, but we should recommend the more portable and
> standardized sys/select.h.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> manual/llio.texi | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/manual/llio.texi b/manual/llio.texi
> index 7b5f77bb7b..e7fd6ca0e9 100644
> --- a/manual/llio.texi
> +++ b/manual/llio.texi
> @@ -2271,8 +2271,8 @@ @node Waiting for I/O
> A better solution is to use the @code{select} function. This blocks the
> program until input or output is ready on a specified set of file
> descriptors, or until a timer expires, whichever comes first. This
> -facility is declared in the header file @file{sys/types.h}.
> -@pindex sys/types.h
> +facility is declared in the header file @file{sys/select.h}.
> +@pindex sys/select.h
>
> In the case of a server socket (@pxref{Listening}), we say that
> ``input'' is available when there are pending connections that could be
> @@ -2286,13 +2286,13 @@ @node Waiting for I/O
> and some macros for manipulating these objects.
>
> @deftp {Data Type} fd_set
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> The @code{fd_set} data type represents file descriptor sets for the
> @code{select} function. It is actually a bit array.
> @end deftp
>
> @deftypevr Macro int FD_SETSIZE
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> The value of this macro is the maximum number of file descriptors that a
> @code{fd_set} object can hold information about. On systems with a
> fixed maximum number, @code{FD_SETSIZE} is at least that number. On
> @@ -2304,14 +2304,14 @@ @node Waiting for I/O
> @end deftypevr
>
> @deftypefn Macro void FD_ZERO (fd_set *@var{set})
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> @safety{@prelim{}@mtsafe{@mtsrace{:set}}@assafe{}@acsafe{}}
> This macro initializes the file descriptor set @var{set} to be the
> empty set.
> @end deftypefn
>
> @deftypefn Macro void FD_SET (int @var{filedes}, fd_set *@var{set})
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> @safety{@prelim{}@mtsafe{@mtsrace{:set}}@assafe{}@acsafe{}}
> @c Setting a bit isn't necessarily atomic, so there's a potential race
> @c here if set is not used exclusively.
> @@ -2322,7 +2322,7 @@ @node Waiting for I/O
> @end deftypefn
>
> @deftypefn Macro void FD_CLR (int @var{filedes}, fd_set *@var{set})
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> @safety{@prelim{}@mtsafe{@mtsrace{:set}}@assafe{}@acsafe{}}
> @c Setting a bit isn't necessarily atomic, so there's a potential race
> @c here if set is not used exclusively.
> @@ -2333,7 +2333,7 @@ @node Waiting for I/O
> @end deftypefn
>
> @deftypefn Macro int FD_ISSET (int @var{filedes}, const fd_set *@var{set})
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> @safety{@prelim{}@mtsafe{@mtsrace{:set}}@assafe{}@acsafe{}}
> This macro returns a nonzero value (true) if @var{filedes} is a member
> of the file descriptor set @var{set}, and zero (false) otherwise.
> @@ -2345,7 +2345,7 @@ @node Waiting for I/O
> Next, here is the description of the @code{select} function itself.
>
> @deftypefun int select (int @var{nfds}, fd_set *@var{read-fds}, fd_set *@var{write-fds}, fd_set *@var{except-fds}, struct timeval *@var{timeout})
> -@standards{BSD, sys/types.h}
> +@standards{POSIX.1, sys/select.h}
> @safety{@prelim{}@mtsafe{@mtsrace{:read-fds} @mtsrace{:write-fds} @mtsrace{:except-fds}}@assafe{}@acsafe{}}
> @c The select syscall is preferred, but pselect6 may be used instead,
> @c which requires converting timeout to a timespec and back. The
> @@ -2420,9 +2420,6 @@ @node Waiting for I/O
> @end table
> @end deftypefun
>
> -@strong{Portability Note:} The @code{select} function is a BSD Unix
> -feature.
> -
> Here is an example showing how you can use @code{select} to establish a
> timeout period for reading from a file descriptor. The @code{input_timeout}
> function blocks the calling process until input is available on the
More information about the Libc-alpha
mailing list