Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 1998 07:25:50 -0500 (EST)
From:      Daniel Eischen <eischen@vigrid.com>
To:        bde@zeta.org.au, cejkar@dcse.fee.vutbr.cz, freebsd-current@FreeBSD.ORG
Subject:   Re: mkfifo()/select() & O_RDONLY serious bug?
Message-ID:  <199812111225.HAA29472@pcnet1.pcnet.com>

next in thread | raw e-mail | index | archive | help
> >I have prepared small testing program (listed at the end) with mkfifo()
> >and select() calls. Fifo is opened as O_RDONLY or O_RDWR with O_NONBLOCK.
> >On FreeBSD 3.0-CURRENT, its behavior is different from other systems.
> >I think it is serious bug: select() returns that there is ready file
> >descriptor but descriptor is not ready in fact. I'm right?
>
> I think it's a feature :-).  The descriptor is ready for reading.
> read() will succeed and return 0 (EOF) because the mode is O_NONBLOCK and
> there are no writers.  This is as specified by POSIX.1.  POSIX.1 doesn't
> specify select(), and the FreeBSD implementation is simply that select()
> returns success if read() would succeed immediately.

I just caught this thread, so I may have missed something...

This seems wrong.  How do you wait for data availability from a 
file [descriptor] in non-blocking mode?  You continuously spin
in a select/read loop?  

If the file is opened in non-blocking mode, then a select (with
timeout) is not needed to avoid blocking indefinitely because
read() can do that.  So if someone uses select with a non-blocking
file descriptor, then you've got to assume that they want to know
when data is ready and waiting; they don't want select to tell
them that there isn't any data.

Dan Eischen
eischen@vigrid.com

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



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