Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2000 07:35:50 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Peter van Dijk <peter@dataloss.net>, ache@freebsd.org
Cc:        current@FreeBSD.ORG
Subject:   Re: FIFOs & select: what about our implementation?
Message-ID:  <Pine.BSF.4.21.0009060543430.25048-100000@besplex.bde.org>
In-Reply-To: <20000905192458.A1428@dataloss.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 5 Sep 2000, Peter van Dijk wrote:

> On Tue, Sep 05, 2000 at 07:50:56PM +0400, Andrey A. Chernov wrote:
> > Consider this comment comes from screen(1):
> > 
> > /*
> >  * Define this if your system exits select() immediatly if a pipe is
> >  * opened read-only and no writer has opened it.
> >  */
> > #define BROKEN_PIPE 1
> > 
> > We have broken(?) pipe, according to this statement. At least, we have
> > select return code -1 with wrong errno == 0.
> 
> qmail calls this 'named pipe bug 1'. The workaround (which screen
> probably uses too) is to let the process doing the select() also have
> one fd opened for writing on the pipe. With that write-open, select()
> will only return if there is actual data waiting inside the pipe.
> 
> I have filed a PR (19871) for this I think about 2 months ago, somebody
> submitted a patch but I never gotten around to testing it.
> 
> I surely do think this behaviour is broken.

This behaviour is sort of intentional.  Reads on a named pipe with no
writers are specified by POSIX.1 to return immediately.  4.4BSD does
extra work to break this in some cases.  select() on a read descriptor
open on such a pipe just follows read().  I think it started giving
the behaviour that you don't want when I fixed read().

Linux gives the behaviour that you want by not following read() in
select() (more (precisely, in poll()).  It puts POLLHUP in the events
polled for read descriptors in select() and actually implements POLLHUP
for named pipes.  The special handling for select() then falls out of
the special handling for POLLHUP (polling on POLLHUP doesn't succeed
until there has been a writer).  FreeBSD doesn't do either of these
things.  It is also missing support for POLLHUP on ttys and sockets.

Bruce



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?Pine.BSF.4.21.0009060543430.25048-100000>