From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 1 07:30:07 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4B1116A419 for ; Mon, 1 Oct 2007 07:30:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 87EF413C4B2 for ; Mon, 1 Oct 2007 07:30:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l917U7Lj052647 for ; Mon, 1 Oct 2007 07:30:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l917U7b3052645; Mon, 1 Oct 2007 07:30:07 GMT (envelope-from gnats) Date: Mon, 1 Oct 2007 07:30:07 GMT Message-Id: <200710010730.l917U7b3052645@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Bruce Evans Cc: Subject: Re: kern/116770: Unfortunate fifo/O_NONBLOCK/kevent interaction X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bruce Evans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2007 07:30:07 -0000 The following reply was made to PR kern/116770; it has been noted by GNATS. From: Bruce Evans To: Bo Lindbergh Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Subject: Re: kern/116770: Unfortunate fifo/O_NONBLOCK/kevent interaction Date: Mon, 1 Oct 2007 17:26:02 +1000 (EST) On Sun, 30 Sep 2007, Bo Lindbergh wrote: >> Description: > When a fifo with no writers is opened nonblockingly for reading and > the resulting file descriptor is added to a kqueue, kevent will > immediately report an EOF condition. This is less than useful. But it is an EOF condition: in this state, read() must return 0 to indicate EOF. select(), poll() and kqueue could have another mechanism for reporting this state, but don't in FreeBSD. Some other OS's have a specially broken select() and/or poll() for fifos but not for other file types so that the polling read condition doesn't actually report the read condition for fifos only. >> Fix: > Don't CANTRCVMORE the socketpair immediately after creating it. Add > code to fifo_read_f to avoid calling soreceive blockingly when there > are zero writers. That would break read(). > Or just add a fi_seen_at_least_one_writer flag to struct fifoinfo... Fixing this, or even implementing bug for bug compatibility with other OS's, is not easy. See PR's 34020, 53447, 76144, 76125, 76525, 94722 and the resulting commits for previous attempts to fix this. PR 94722 does something like this. It only tries to fix poll(). The behaviour of select() on a read descriptor cannot be changed, except to remove old buggy attempts to fix this problem, since select() on a read descriptor has no way to distinguish initial EOF from hangup. select() on an exceptional descriptor could consider hangup as an exception; there is no standard for this, but since exceptional descriptors are rarely used, changing the behaviour for them wouldn't break much. Kqueue has flags so it should be able to use the fix for poll() fairly easily. Bruce