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

Meaning of sysread()

Thread Next
From:
Nick Ing-Simmons
Date:
May 21, 2003 03:52
Subject:
Meaning of sysread()
Message ID:
20030521105215.1922.7@bactrian.elixent.com

Some of you may have been aware that Sarathy and I have been trying to 
resolve meaning of sysread(). perl5.8.0 breaks some legacy Win32
code which expects sysread() to do CRLF translation (not on sockets...)

Yesterday it became clear reason we were confused is that Sarathy and I 
were working from different 'specs'.

perlfunc.pod and Camel 3rd-edition seem to disagree on fundamentals.

I would like to solicit opinions from perl5-porters on reasons for 
leaning one way or the other.

Here is my latest post in the off-list discussion.

Nick Ing-Simmons <nick.ing-simmons@elixent.com> writes:
>Gurusamy Sarathy <gsar@ActiveState.com> writes:
>>
>>Given sysread() is supposed to read characters, not bytes, 
>
>ARGH!
>
>But that is/was not "given" - I see it says that in perlfunc.pod now
>but it does not say it in Camel-III. (and I don't think the 
>code-as-a-whole does that - it is true for read() but not sysread()).
>
>I cannot reconcile that idea with camel-III's idea that sysread() 
>calls read(2). Cammel-III also explictly says that sysread() can stop
>in the middle of a character.

(I note this morning that it also says that about perl's read().)

>
>Unix does not do characters that way. To get characters
>you need something like :encoding() layer - which is there for perls read()
>but not UNIX read() - and hence sysread() in Camel-III "spec".
>
>But if that is to-be true I begin to see your confusion an perhaps
>even your point.
>
>The essential point to clarify via Pumpking/Larry ruling is 
>which is true:
>  A. sysread() calls read(2) (or goes straight to OS, is "raw", ...)
>  B. sysread() reads characters.
>
>
>(A) seems to break Win32 sysread/CRLF things
>(B) would break UNIX select/sysread things.
>

I am begining to wonder if the sysxxx() things should call something 
like:

PerlIO *sys = PerlIO_syslayer(PerlIO *top);

And then 
  sysread() calls PerlIO_read(sys,...)
  syswrite() calls PerlIO_write(sys,...)

etc. 

Then UNIX'es PerlIO_syslayer would return :unix layer and sysread() would
call read(2) via the table. Win32's PerlIO_syslayer could return :crlf
layer.

Or perhaps it should be a pragma:

use syslayer qw(unix);

Or perhaps it could be wedged into the other bodge - open.pm 
(and so benefit from the existing hack to make that lexical.)

use open (IN => 'this', 'OUT' => that', sys => 'theother');





But that does not realy fix the "reads characters" issue. 




-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About