logo       

RE: stdin set to nonblocking mode: msg#00082

lang.haskell.glasgow.bugs

Subject: RE: stdin set to nonblocking mode

On 12 August 2005 15:11, Sigbjorn Finne wrote:

> "Simon Marlow" <simonmar@xxxxxxxxxxxxx> writes:
>>
> ...
>> No - read() can always return less than the requested amount of data,
>> even when not in O_NONBLOCK mode.
>>
>
> Hmm, care to give some details as to why you equate "can" with
> "always will" on all platforms?

Well, you're right, I'm not sure "always will" is explicitly required,
but I believe it's universally true. The fact that the POSIX spec for
read() only mentions how O_NONBLOCK affects read() when there is no data
available, and doesn't say anything about the effect of O_NONBLOCK when
there is data available, would seem to indicate that O_NONBLOCK doesn't
make any difference in this case.

Here's what POSIX says about short reads, FWIW:

"The value returned may be less than nbyte if the number of bytes left
in the file is less than nbyte, if the read() request was interrupted by
a signal, or if the file is a pipe or FIFO or special file and has fewer
than nbyte bytes immediately available for reading. For example, a
read() from a file associated with a terminal may return one typed line
of data."

http://www.opengroup.org/onlinepubs/009695399/functions/read.html

Cheers,
Simon


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise