Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 May 2001 11:16:09 -0500 (CDT)
From:      Jonathan Lemon <jlemon@flugsvamp.com>
To:        ino-waiting@gmx.net, bugs@freebsd.org
Subject:   Re: kern/27287: poll(2) returns 0 when POLLIN-ing ordinary files
Message-ID:  <200105131616.f4DGG9111221@prism.flugsvamp.com>
In-Reply-To: <local.mail.freebsd-bugs/20010512163436.3789.qmail@spotteswoode.yi.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <local.mail.freebsd-bugs/20010512163436.3789.qmail@spotteswoode.yi.org> you write:
>given a file "trypoll.c" (for relevant lines see below), poll does not see
>that input is ready immediately.  the following code-snipet returns 0 for
>the return value and also 0 in x.revents.
>
>  x.fd = open("trypoll.c",O_RDONLY);
>  if (x.fd == -1) _exit(111);
>  x.events = POLLIN;
>  if (poll(&x,1,10) == -1) _exit(1);
>  if (x.revents != POLLIN) _exit(1);


If you change "POLLIN" to "POLLRDNORM", then this will work as
you expect.  Hoever, it's fairly pointless to poll() on a file,
since it will always return true, no matter what, so the code
above is fairly pointless.

If you really want to poll a file for readability, use kqueue.
--
Jonathan

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105131616.f4DGG9111221>