lkml.org 
[lkml]   [2003]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [2.4] Inconsistency in poll(2)
From
Date
malware@t-online.de (Michael Mueller) writes:

> Hi readers of linux-kernel and glibc maintainers,
>
> while hacking on a network application I found following oddity:
>
> poll(pds,nfds,timeout) called with one of the file descriptors listed in
> pds being invalid always does return nfds.

[snip .. ]

> Simple sample code demonstrating the problem:

When writing code, always compile with at least -Wall -W
>
> #include <stdio.h>
> #include <sys/poll.h>
>
> struct pollfd fds[] = {
> { 0, POLLIN, 0 },
> { 110, POLLIN, 0}
> };
>
> int main(void)
> {
> int r = poll(fds, sizeof fds / sizeof fds[0], -1);
> if ( r < 0 )
> perror("poll");
> else
> printf("poll returned %d\n");
printf("poll returned %d\n", r);

Is probably what you want.

>
> for ( r=0; r < sizeof fds / sizeof fds[0]; r++ )
> printf("revent[%d]: %hd\n", r, fds[r].revents);
>
> return 0;
> }

--
James Antill -- james@and.org
Need an efficent and powerful string library for C?
http://www.and.org/vstr/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.037 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site