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

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

Thread Next
Michael Bell
February 19, 2004 01:20
Re: [perl #26787] read reports wrong eof under high system load
Message ID:
(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). 
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. 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?

Michael Bell                   Email:
ZE Computer- und Medienservice            Tel.: +49 (0)30-2093 2482
(Computing Centre)                        Fax:  +49 (0)30-2093 2704
Humboldt-University of Berlin
Unter den Linden 6
10099 Berlin                   Email (private):

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