From owner-freebsd-current Tue Sep 5 13:36: 3 2000 Delivered-To: freebsd-current@freebsd.org Received: from gidora.zeta.org.au (gidora.zeta.org.au [203.26.10.25]) by hub.freebsd.org (Postfix) with SMTP id 058BB37B424 for ; Tue, 5 Sep 2000 13:35:59 -0700 (PDT) Received: (qmail 2627 invoked from network); 5 Sep 2000 20:35:53 -0000 Received: from unknown (HELO bde.zeta.org.au) (203.2.228.102) by gidora.zeta.org.au with SMTP; 5 Sep 2000 20:35:53 -0000 Date: Wed, 6 Sep 2000 07:35:50 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Peter van Dijk , ache@freebsd.org Cc: current@FreeBSD.ORG Subject: Re: FIFOs & select: what about our implementation? In-Reply-To: <20000905192458.A1428@dataloss.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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