From owner-freebsd-bugs Mon Jul 17 4:30: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 6445C37B92E for ; Mon, 17 Jul 2000 04:30:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id EAA79255; Mon, 17 Jul 2000 04:30:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Mon, 17 Jul 2000 04:30:04 -0700 (PDT) Message-Id: <200007171130.EAA79255@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: RE: gnu/19871: select bug on named pipes Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/19871; it has been noted by GNATS. From: Bruce Evans To: John Baldwin Cc: sheldonh@FreeBSD.ORG Subject: RE: gnu/19871: select bug on named pipes Date: Sat, 15 Jul 2000 21:40:08 +1000 (EST) On Fri, 14 Jul 2000, John Baldwin wrote: > On 14-Jul-00 Sheldon Hearn wrote: > > Since you've had your fingers in the select code recently, could you > > perhaps check out PR gnu/19871? (The gnu is inaccurate; the originator > > meant for it to be kern). :-) > > Umm, well, I'm not _that_ familiar with the code, but I could look at > it I guess. I fixed read() to on an empty fifo with no writers to conform with POSIX. POSIX requires it to return successfully without blocking. In 4.4BSD it has some brokenness related to giving behaviour like the author of the PR wants. select() on read descriptors open on fifos just returns when a !O_NONBLOCK read() on one of them would return successfully without blocking. This is always the case for reads on a fifo with no writers. Linux's select() handles fifos specially so that select() doesn't just follow read(). SUSv2 specifies select() but doesn't seem to specify anything special for pipes. Therefore, the FreeBSD behaviour is a feature :-). ISTR a previous FR (maybe not in gnats) about this. FreeBSD has some related bugs in poll(). It only implements POLLHUP for ttys and nameless pipes. Under Linux, POLLHUP is set for polls on a fifo with no writers if there was a writer in the (immediately?) previous generation, and read-select() checks POLLHUP. This is necessary to give the correct behaviour for read-select() on a fifo whose last writer recently went away (select() must not block in this case). This should be fixed by someone who understands sockets a bit better than me. Named pipes are implemented as sockets, and some of the bugs may be for sockets generally. I think POLLHUP should be set when a socket is disconnected... Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message