From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Typo in <sys/select.h>?
Date: Wed, 6 Jul 2022 17:07:14 +0200 [thread overview]
Message-ID: <YsWlIkz7QTwSK9g1@calimero.vinschen.de> (raw)
In-Reply-To: <DM8PR09MB709506526ACE1ACB3E0E41F3A5809@DM8PR09MB7095.namprd09.prod.outlook.com>
On Jul 6 14:26, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
> > DESCRIPTION
> > WARNING: select() can monitor only file descriptors numbers that are
> > less than FD_SETSIZE (1024)-an unreasonably low limit for many modern
>
> Whoever wrote this, was wrong (they might have never consulted the actual kernel code, or were just
> blindsided by FD_SETSIZE being a predefined constant). You can take a look at the kernel source code,
> if you don't believe me.
>
> This select() trick has been like that from the earliest days of Linux, and the behavior is carefully carried over.
>
> https://github.com/torvalds/linux/blob/master/fs/select.c#L625
>
> It's just an FYI :-)
:+1:
You're right as far as the kernel is concerned. The problem is apparently
in glibc. From the same man page:
POSIX allows an implementation to define an upper limit, advertised via
the constant FD_SETSIZE, on the range of file descriptors that can be
specified in a file descriptor set. The Linux kernel imposes no fixed
limit, but the glibc implementation makes fd_set a fixed-size type,
with FD_SETSIZE defined as 1024, and the FD_*() macros operating ac‐
cording to that limit. To monitor file descriptors greater than 1023,
use poll(2) or epoll(7) instead.
And that's still the case with glibc from current git master:
bits/typesizes.h:
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
That's defined unconditionally, just as this stuff from sys/select.h:
misc/sys/select.h:
/* fd_set for select and pselect. */
typedef struct
{
/* XPG4.2 requires this member name. Otherwise avoid the name
from the global namespace. */
#ifdef __USE_XOPEN
__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->fds_bits)
#else
__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->__fds_bits)
#endif
} fd_set;
/* Maximum number of file descriptors in `fd_set'. */
#define FD_SETSIZE __FD_SETSIZE
However, discussing this shows how irrelevant the actual default value
of FD_SETSIZE is. Per POSIX, it's just that, a default value. In
interested process which thinks it needs higher fd numbers should make
sure to define FD_SETSIZE according to its requirements anyway.
Corinna
next prev parent reply other threads:[~2022-07-06 15:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 14:26 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 15:07 ` Corinna Vinschen [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-06 15:57 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 17:03 ` Ken Brown
2022-07-06 14:17 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 13:19 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 14:17 ` Corinna Vinschen
2022-07-05 15:11 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-05 14:13 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-05 14:55 ` Andrey Repin
2022-07-05 21:51 ` Ken Brown
2022-07-06 7:42 ` Corinna Vinschen
2022-07-06 14:01 ` Jon Turney
2022-07-06 14:15 ` Corinna Vinschen
2022-07-06 14:22 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YsWlIkz7QTwSK9g1@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).