Typo in <sys/select.h>?

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Jul 6 14:22:47 GMT 2022


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


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /