lkml.org 
[lkml]   [2010]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch/rfc] Make poll/select report error (POLLNVAL and EBADF) for unsupported files
On Wed, 17 Feb 2010, THIELL Stephane wrote:

>
> > On Mon, 15 Feb 2010, Eric Dumazet wrote:
> >
> >
> > > Hmm, according to POSIX :
> > >
> > > The poll() function shall support regular files, terminal and
> > > pseudo-terminal devices, FIFOs, pipes, sockets ...
> > >
> > > Regular files shall always poll TRUE for reading and writing.
> > >
> > >
> As POSIX says poll(2) have to support regular files (and it seems all possible
> user file descriptors), then wouldn't it be better/more coherent to have
> epoll(7) behave the same way (ie. support regular files instead of
> epoll_ctl(2) returning EPERM), in order to allow generic code handling both
> very common situations like:
>
> $ cat replay_file | application
> and
> $ application < replay_file
>
> ...where for instance the application doesn't know the origine of its fd 0
> (pipe, file, or something else).

Most definitely no. POSIX behavior is just stupid, and should have been
implemented by not having to report things/events that are not true.
Now, that's POSIX, and we cannot break its APIs.
New ones though, do not need to be necessarily stupid.
Besides, epoll needs an f_op->poll to work, and this would require all FS
files to implement a bogus f_op->poll which simply returns the full event
mask.
Which is just plain silly.
For things like epoll ET, this will simply not work, and even for LT,
you'd get every time out of epoll_wait() because you have something there
that always reports every event you ask, even though it is not true.


- Davide




\
 
 \ /
  Last update: 2010-02-17 19:19    [W:0.037 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site