Error in poll implementation?

Andreas Jaeger (aj@arthur.rhein-neckar.de)
Wed, 24 Jun 1998 09:46:35 +0200 (CEST)


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 :-(.

I've looked up the documentation and found the following two
references:

Unix98 says:
"If the value of fd is less than 0, events is ignored and
revents is set to 0 in that entry on return from
poll()."

Stevens (Unix Network Programming, Volume 1, 2nd Edition, p. 171) has:
"If we are no longer interested in a particular descriptor, we just
set the fd member of the pollfd structure to a negative value. Then
the events member is ignored and the revents member is set to 0 on
return."

Here's a sample output to see what happens:
Before calling poll (read_polls, 16, -1):
read_polls[ 0] is: fd: 3, events: 0x000040, revents:000000
read_polls[ 1] is: fd: -1, events: 000000, revents:000000
read_polls[ 2] is: fd: -1, events: 000000, revents:000000
...
read_polls[15] is: fd: -1, events: 000000, revents:000000

After calling poll (read_polls, 16, -1):
read_polls[ 0] is: fd: 3, events: 0x000040, revents:000000
read_polls[ 1] is: fd: -1, events: 000000, revents:0x000020
read_polls[ 2] is: fd: -1, events: 000000, revents:0x000020
...
read_polls[15] is: fd: -1, events: 000000, revents:0x000020

poll returned 15 and set errno to 4.

Is this really an error in the kernel? Has anybody a fix for it?

My system characteristics: Linux 2.1.106ac4 compiled with gcc 2.7.2.3,
i486, glibc 2.1 snapshot.

Thanks,
Andreas

-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@alma.student.uni-kl.de

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