Typo in <sys/select.h>?

Andrey Repin anrdaemon@yandex.ru
Tue Jul 5 14:55:19 GMT 2022


Greetings, Lavrentiev, Anton (NIH/NLM/NCBI) [C]!

> There's some inconsistency between <sys/select.h> and <sys/param.h>:

> sys/select.h has this:
> -----------------------
> /*
>  * Select uses bit masks of file descriptors in longs.
>  * These macros manipulate such bit fields (the filesystem macros use chars).
>  * FD_SETSIZE may be defined by the user, but the default here
>  * should be >= NOFILE (param.h).
>  */
> #ifndef FD_SETSIZE
> #define FD_SETSIZE      64
> #endif
> ----------------------

> Now, this is the relevant part of sys/param.h looks like this:
> ----------------------
> /* Max number of open files.  The Posix version is OPEN_MAX.  */
> /* Number of fds is virtually unlimited in cygwin, but we must provide
>    some reasonable value for Posix conformance */
> #define NOFILE          8192
> ----------------------

> So it's either "<= NOFILE" that was actually meant to be there in the comment (or,
> an equivalent "should NOT be > NOFILE"), or FD_SETSIZE should have been defined as 8192,
> if the comment is actually correct.  Or maybe I'm missing something here :-)

> I understand that if I redefined FD_SETSIZE in my code before including <sys/select.h>,
> it'd work with whatever large (or small) fd_set I need, but that's not what I'm after.

I'm no expert, but it seems the FD_SETSIZE should have been 128.
Long is 8 bytes, 64 bits. One bit if one open file, 64 * 64 = 4096.


-- 
With best regards,
Andrey Repin
Tuesday, July 5, 2022 17:52:26

Sorry for my terrible english...



More information about the Cygwin mailing list