This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: FD_SETSIZE and sizeof(fd_set)
- From: Steven Bardwell <SBardwell at lbmsys dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Thu, 23 Jun 2016 11:36:35 +0000
- Subject: RE: FD_SETSIZE and sizeof(fd_set)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=SBardwell at lbmsys dot com;
- References: <DM3PR18MB084148FC4EFA327DA33DB267DB2C0 at DM3PR18MB0841 dot namprd18 dot prod dot outlook dot com> <nkf6f4$304$1 at ger dot gmane dot org> <nkfenq$n3h$1 at ger dot gmane dot org> <DM3PR18MB0841BD59B02E2CDAE372F2CCDB2D0 at DM3PR18MB0841 dot namprd18 dot prod dot outlook dot com> <59cb34fb-3173-4af9-1b6d-17cef98b7934 at mitel dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
> >
> > Here is a "program" that shows the issue I am worried about. It is so simple
> that I must be overlooking something really obvious:
> >
> > #include <stdio.h>
> > #undef FD_SETSIZE
> > #define FD_SETSIZE 256
> > #include <sys/types.h>
> > #include <sys/select.h>
> >
> > main()
> > {
> > fd_set rfds;
> > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > }
> >
> > Steve Bardwell
> >
> >
>
> I don't know if this is still the case, but when I looked into this years ago I
> found that it was not possible to change the size of the fd set in linux, it's
> fixed at 1024 (generally), unless you rebuild the kernel.
>
> Secondly, in the windows api, their version of an fd_set is more like a poll()
> implementation, you can fake out any size you want since the size of the
> array is the first entry.
>
> I can't speak for the cygwin implementations, but if they offer poll() or,
> better, epoll(), use those.
>
> -lee
For what it's worth, this 'program' works as expected in SUA. The size of the fd_set changes depending on the value of FD_SETSIZE.
Steve Bardwell