develooper Front page | perl.perl5.porters | Postings from May 2003

Re: Meaning of sysread()

Thread Previous | Thread Next
Nick Ing-Simmons
May 30, 2003 02:10
Re: Meaning of sysread()
Message ID:
Kurt Starsinic <> writes:
>On May 24, Ton Hospel wrote:
>> Or if you must for backward compatibility on windows,
>> (though personally i'd consider \r\n games on sysread
>> a windows bug), at least define sysread on a
>> binmode handle to be *ALWAYS* byte semantics.
>    Just once more, I'd like to assert that sysread() should do
>whatever C's read() does, however weird or broken that may or may
>not be on any given platform.  Its only usefulness that I can see
>is to "do a read that works the same as in my C program".

The snag here is what read() does in your Win32 C program depends 
on how you open()ed it. 

For sysread() the fd was open()ed to suit <$fh>  via the layer stack.
In 5.8.0 this means fd is in binary mode NOT doing the CRLF translation
as :crlf layer does that. Then sysread() calls read(2) and gets binary 
data and Win32 users are surprised. (In perl5.6 the fd is opened in O_TEXT 
mode as that is how 5.6 via Win32's stdio does CRLF stuff.)
(Note that for historical pragmatic reasons even in perl5.6 sockets
are "opened" as O_BINARY.)

It would be easy enough to make sysopen() + sysread() behave like your C

Nick Ing-Simmons

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