From owner-freebsd-arch@FreeBSD.ORG Wed Apr 9 04:20:56 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8BAE837B401; Wed, 9 Apr 2003 04:20:56 -0700 (PDT) Received: from snark.ratmir.ru (snark.ratmir.ru [213.24.248.177]) by mx1.FreeBSD.org (Postfix) with ESMTP id 64DFE43F93; Wed, 9 Apr 2003 04:20:55 -0700 (PDT) (envelope-from freebsd@snark.ratmir.ru) Received: from snark.ratmir.ru (freebsd@localhost [127.0.0.1]) by snark.ratmir.ru (8.12.9/8.12.9) with ESMTP id h39BKrDR033375; Wed, 9 Apr 2003 15:20:54 +0400 (MSD) (envelope-from freebsd@snark.ratmir.ru) Received: (from freebsd@localhost) by snark.ratmir.ru (8.12.9/8.12.9/Submit) id h39BKl48033374; Wed, 9 Apr 2003 15:20:47 +0400 (MSD) Date: Wed, 9 Apr 2003 15:20:47 +0400 From: Alex Semenyaka To: "Andrey A. Chernov" Message-ID: <20030409112047.GB33265@snark.ratmir.ru> References: <20030408164614.GA7236@comp.chem.msu.su> <20030409044301.J628@gamplex.bde.org> <20030408194944.GA43822@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030408194944.GA43822@nagual.pp.ru> User-Agent: Mutt/1.5.4i cc: arch@freebsd.org cc: Yar Tikhiy Subject: Re: termios & non-blocking I/O X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Apr 2003 11:20:56 -0000 On Tue, Apr 08, 2003 at 11:49:44PM +0400, Andrey A. Chernov wrote: > IEEE Std 1003.1-200x does not specify whether the setting of O_NONBLOCK > takes precedence over MIN or TIME settings. Therefore, if O_NONBLOCK is > set, read( ) may return immediately, regardless of the setting of MIN or > TIME. Also, if no data is available, read( ) may either return 0, or > return -1 with errno set to [EAGAIN]. Right you are, but the question is a little bit different, namely - what is _better_ to do: to return 0 or to return -1/EAGAIN. Now the first choice is implemented. And the point IS that in multi-thread environment with utheads such implementation leads to BAD results. The progarm considers the descriptor as being in blocking mode while libc_r hiddenly (for user) set it up to non-blocking operation mode. So 0 returned to the program can be considered only as EOF while it is NOT. And is IS definitely the WRONG behaviour. Sure user's thread system cannot deal with the descriptors in blocking mode. But it should simulate it somehow. Yar described the example when the such simulation is totally broken. SY, Alex