Re: Error in poll implementation?

Mike (ford@omnicron.com)
Wed, 24 Jun 98 02:10:07 -0700


> I do think there's an error in the implementation of the poll system
> call in linux 2.1.106. In one application I set the fd field to
> -1 to ignore that field. The call returns immediatly and doesn't
> ignore the field :-(.

Yup, looks like a bug. Even SVR4 specifies ignoring negative fds.
Here's a candidate fix, which I have not tested except that it compiles.
This patch is against kernel 2.1.105ac5 (sorry, it's what I had handy).

-=] Ford [=-

"That's high quality Velcro. Can you (In Real Life: Mike Ditto)
get this spot out? More Tang, Mom." ford@omnicron.com
-- Jerry Steiner http://www.omnicron.com/~ford/ford.html

--- fs/ORIGselect.c Mon Mar 23 10:13:52 1998
+++ fs/select.c Wed Jun 24 01:39:24 1998
@@ -300,15 +300,16 @@
unsigned int mask;
struct file * file;

- mask = POLLNVAL;
+ if (fdpnt->fd < 0)
+ mask = 0;
/* poll_wait increments f_count if needed */
- file = fcheck(fdpnt->fd);
- if (file != NULL) {
+ else if ((file = fcheck(fdpnt->fd)) != NULL) {
mask = DEFAULT_POLLMASK;
if (file->f_op && file->f_op->poll)
mask = file->f_op->poll(file, wait);
mask &= fdpnt->events | POLLERR | POLLHUP;
- }
+ } else
+ mask = POLLNVAL;
if (mask) {
wait = NULL;
count++;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu