From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Typo in <sys/select.h>?
Date: Wed, 6 Jul 2022 16:22:47 +0200 [thread overview]
Message-ID: <YsWat3DLV9KEH/UG@calimero.vinschen.de> (raw)
In-Reply-To: <YsWZHryhvF3+WcEv@calimero.vinschen.de>
On Jul 6 16:15, Corinna Vinschen wrote:
> On Jul 6 15:01, Jon Turney wrote:
> > Remember that 64 is MAXIMUM_WAIT_OBJECTS for WaitForMultipleObjects(), the
> > underlying Win32 API used to implement select(), so using more than 64 hits
> > some complex code to work around that...
>
> This isn't what FD_SETSIZE is about. FD_SETSIZE does *NOT* define the
> maximum count of fd's in an fd_set.
>
> It defines the maximum fd number usable in an fd_set.
>
> So if FD_SETSIZE is defined low enough:
>
> #define FD_SETSIZE 3
> #include <sys/select.h>
>
> /* Only fd's 0, 1, and 2 will be allowed in this fd_set */
> fd_set set;
>
> FD_ZERO (&set);
> /* This will probaly set fd to 3 */
> fd = open ("foo", O_RDONLY);
> /* So this will (hopefully) fail */
> FD_SET (fd, &set);
Right, this isn't quite how it works, given fd_set is a bitfield using
unsigned long as basetype under the hood. This should just outline
the idea behind FD_SETSIZE.
Corinna
next prev parent reply other threads:[~2022-07-06 14:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-07-05 15:11 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-06 14:17 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 14:26 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 15:07 ` Corinna Vinschen
2022-07-06 15:57 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 17:03 ` Ken Brown
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=YsWat3DLV9KEH/UG@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).