All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Antill <james@and.org>
To: malware@t-online.de (Michael Mueller)
Cc: linux-kernel@vger.kernel.org, glibc-sc@gnu.org
Subject: Re: [2.4] Inconsistency in poll(2)
Date: 18 Jul 2003 13:13:56 -0400	[thread overview]
Message-ID: <m3fzl3pxkb.fsf@code.and.org> (raw)
In-Reply-To: <200307161032.MAA09922@fire.malware.de>

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/

      parent reply	other threads:[~2003-07-18 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 10:35 [2.4] Inconsistency in poll(2) Michael Mueller
2003-07-16 12:07 ` Michael Mueller
2003-07-18 17:13 ` James Antill [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fzl3pxkb.fsf@code.and.org \
    --to=james@and.org \
    --cc=glibc-sc@gnu.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malware@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.