Date: Wed, 9 Apr 2003 15:20:47 +0400 From: Alex Semenyaka <alexs@ratmir.ru> To: "Andrey A. Chernov" <ache@nagual.pp.ru> Cc: Yar Tikhiy <yar@freebsd.org> Subject: Re: termios & non-blocking I/O Message-ID: <20030409112047.GB33265@snark.ratmir.ru> In-Reply-To: <20030408194944.GA43822@nagual.pp.ru> References: <20030408164614.GA7236@comp.chem.msu.su> <20030409044301.J628@gamplex.bde.org> <20030408194944.GA43822@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030409112047.GB33265>