Re: RFC: poll change

Tim Hockin (
Tue, 14 Aug 2001 17:09:00 -0700

"David S. Miller" wrote:
> From: Tim Hockin <>
> Date: Tue, 14 Aug 2001 16:53:43 -0700
> The standard says negative fd's are ignored. We get that right. What we
> are left with is an overly paranoid check against max_fds. This check
> should go away. You should be able to pass in up to your rlimit fds, and
> let negative ones (holes or tails) be ignored.
> I am saying there is no problem.
> In both cases, for a properly written application we ignore the
> invalid fds. The behavior is identical both before and after
> your change, so there is no reason to make it.

But for an application that (imho) is poorly written but IS COMPLIANT, it

This program is compliant, if your ulimit -n is maxxed out at 1048576.

I'm not saying it is good design, but it is compliant. The patch hurts
nothing and makes poll() that little bit more friendly.

#include <stdio.h>
#include <sys/poll.h>
#include <errno.h>
#include <string.h>

static struct pollfd ar[1024*1024];
int size = sizeof(ar)/sizeof(*ar);
int i;

for (i = 0; i < size; i++)
ar[i].fd = -1;
ar[1000000].fd = 0;
ar[1000000].events = POLLIN;

i = poll(ar, size, -1);
printf("return = %d (%s)\n", i, i?strerror(errno):"success");

return 0;

Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at