lkml.org 
[lkml]   [2010]   [Feb]   [15]   [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 Mon, 15 Feb 2010, Eric Dumazet wrote:

> Le dimanche 14 février 2010 à 14:27 -0800, Davide Libenzi a écrit :
> > Currently poll and select consider a non poll-supported file as one with
> > full event mask set, instead of reporting proper error to the caller.
> > This behavior can fool the caller of proper functionality being returned,
> > while instead no valid event was processed/read from the device.
> > This came out linked to this bug report:
> >
> > http://bugzilla.kernel.org/show_bug.cgi?id=15272
> >
> > IMHO, it'd be more adequate to report proper error code, for files that do
> > not support f_op->poll(), but then I am also not sure how much breakage
> > can this bring to existing (already broken "in just the right way")
> > applications.
> > Untested, discussion-only, patch.
> >
> >
> > Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
> >
> >
> > - Davide
>
> 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.
>
>
> So unless I missed something, this patch could break some conformant
> applications.

If that's POSIX, than the patch is no good. I missed the part on the
regular files being always ready, which explaqins why the code is as it is
right now.


> In particular, if an application is polling() on stdin (usually a tty),
> and other 'files', what's happening if we do :
>
> cat replay_file | application
>
> Either it wont read stdin, or application exits without reading its
> input.

That case would be fine, since that's a pipe.
This will behave differently:

$ application < replay_file

Anyway, since POSIX states the above, the patch cannot apply.


- Davide

\
 
 \ /
  Last update: 2010-02-15 18:53    [from the cache]
©2003-2011 Jasper Spaans