RE: Poll Error

David Schwartz (davids@webmaster.com)
Mon, 29 Nov 1999 22:12:04 -0800


Linux has a bogus sanity check. The one-line add below should fix it. The
kernel should be comparing the number of poll entries against your resource
limit, not your current file table size.

DS

> #include <sys/resource.h>
> #include <asm/poll.h>
> #include <errno.h>
>
> main (void)
> {
> struct pollfd pfds [10000];
> int pollnum=257, retval;
> struct rlimit rlim;
>
> getrlimit (RLIMIT_NOFILE, &rlim);
> printf ("Cur %d Max %d\n", rlim.rlim_cur,
> rlim.rlim_max);
> rlim.rlim_cur = rlim.rlim_max = 32768;
> if (setrlimit (RLIMIT_NOFILE, &rlim) != 0)
> printf ("Error in setting max FDs %s\n",
> strerror(errno));
> getrlimit (RLIMIT_NOFILE, &rlim);
> printf ("Cur %d Max %d\n", rlim.rlim_cur,
> rlim.rlim_max);
>
> memset (pfds, 0, sizeof(struct pollfd)*10000);
>
dup2(0, pollnum);
>
> for (;;)
> {
> retval = poll (pfds, pollnum, 10*1000);
> if (retval > 0)
> break;
> if (retval < 0)
> {
> printf ("Poll error %s\n", strerror(errno));
> return (-1);
> }
> }
> }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/