develooper Front page | perl.perl5.porters | Postings from February 2004

Re: [perl #26787] read reports wrong eof under high system load

Thread Previous | Thread Next
Nick Ing-Simmons
February 19, 2004 08:14
Re: [perl #26787] read reports wrong eof under high system load
Message ID:
Michael Bell <> writes:
>(Ton Hospel) via RT wrote:
>> In article <>,
>> 	Michael Bell (via RT) <> writes:
>>>If a Linux system runs with a high system load then it can happen
>>>that "read" returns a 0 but it is no EOF. The perldocumentation
>>>"man perlfunc" includes the statement that a zero only happens at
>>>EOF. We tested the same situation with a Solaris system which
>>>does not produce this error.
>> Personally I'd rather see this reported as a linux bug. Do
>> you have code to reproduce this ?
>No, I have no small script to do this. We found this problem during 
>testing a batch system for a PKI (OpenCA). The problem only happens if 
>you have more than 90 percent total system load.
>I don't think that it is a Linux bug because this behaviour is compliant 
>to the POSIX specs. I think that Perl is not aware of the latest POSIX 
>specs (blocking read can return zero characters and this is correct). 

Hmm, I thought I was aware of this and so would have made Perl aware 
of it. 

I am still not clear what is at fault though - is it that perl's read()
returns 0 or perl guts' calls to PerlLIO_read() (i.e. read(2)) fail
to account for zero return?

>BTW I think that the real bug is in the POSIX specs because there is not 
>explicitly written that a zero always signals EOF if it is a blocking 
>read on a regular file. 

But given that we don't really want to have to fstat() to find out it is
a regular file and fctrl() to find out it is blocking I would rather 
calls to read(2) handled zero return in a manner that was consistent 
with use on a non-blocking socket/pipe/tty. Which should make the 
corner case for regular file work too.

>I like the Solaris behaviour much more than the 
>Linux one's.
>My problem is that this beahviour means that there is no real blocking I 
>/O. The only chance to find a EOF after a POSIX read is now
>pos = lseek (fildes, 0, SEEK_CUR);
>fstat (fildes, buf);
>if (pos >= buf.st_size) ...
>This only works for regular files. Again I think that a returned zero 
>should signal EOF but the POSIX specs doesn't define this and the 
>question is now is this wanted by the authors or not?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About