From owner-freebsd-current Fri Dec 11 04:26:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA29593 for freebsd-current-outgoing; Fri, 11 Dec 1998 04:26:34 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA29588 for ; Fri, 11 Dec 1998 04:26:32 -0800 (PST) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id HAA29472; Fri, 11 Dec 1998 07:25:50 -0500 (EST) Date: Fri, 11 Dec 1998 07:25:50 -0500 (EST) From: Daniel Eischen Message-Id: <199812111225.HAA29472@pcnet1.pcnet.com> To: bde@zeta.org.au, cejkar@dcse.fee.vutbr.cz, freebsd-current@FreeBSD.ORG Subject: Re: mkfifo()/select() & O_RDONLY serious bug? Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > >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