On Jul 6 15:01, Jon Turney wrote: > On 06/07/2022 08:42, Corinna Vinschen wrote: > > On Jul 5 17:51, Ken Brown wrote: > > > On 7/5/2022 10:13 AM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin > > > wrote: > > > > I guess we can change FD_SETSIZE to 1024 as on Linux, albeit this has no > > real meaning on Cygwin. On Linux, select(2) is really only capable to > > handle file descriptors numbers up to descriptor number 1023, but Cygwin > > doesn't have this problem. FD_SETSIZE == 64 was only something to save > > space. The bigger FD_SETSIZE, the bigger are the default fd_sets, > > something you don't want on small targets. > > > > So, yeah, something like > > > > #ifndef FD_SETSIZE > > # ifdef __CYGWIN__ > > # define FD_SETSIZE 1024 > > # else > > # define FD_SETSIZE 64 > > # endif > > #endif > > 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); Corinna -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple