[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] sys{open,close,read} and non-sys cousins



At 09:20 -0500 98/06/11, Mark Manning/Simulacron I wrote:
> On the usage of OPEN with SYSREAD.  You didn't read/remember my entire
> message.  I said:
>
> 	SYSOPEN
> 	SYSREAD
> 	SYSWRITE
> 	CLOSE

Someone can tell me I'm wrong, but...

As near as I can tell going through the Camel, there is no documented
reason not to use open() with sysread() or sysopen() with read(), or to
even assume that the sys* functions are somehow "better" than their
non-sys-prefixed counterparts, or more useful for certain types of data,
or...  Just different.  TMTOWTDI.  However, they do point out that mixing
read with sysread or write with print is courting trouble...

sysopen does a C-style open(2); open does a C-style fopen(3).
The first is a system call, the second is from the stdio library. System
calls are more "raw"; the stdio library adds some extra stuff.
That's on Unix of course :-)

Same for read vs. sysread

The "opposite" of syswrite is print.  write() is a different beastie
altogether; keeps the programmer on his toes. :-)

> > (And why the CLOSE statement works with the rest of that stuff I have no
> > idea.  I would have thought there would have been a SYSCLOSE.)

Good question (ask Larry?).  Unix/C has both the stdio library fclose and
the system call close.  fclose causes unbuffered data to be written; close
just closes the file descriptor.  Maybe the Perl author(s) didn't see the
need for the close (sysclose) variant.  After all, regardless of the
underlying implementation, this is still Perl, not C.

Vicki
---
Vicki Brown, vlb@cfcl.com        |\      _,,,---,,_
Journeyman Sourceror      ZZZzz /,`.-'`'    -.  ;-;;,_
Scripts & Philtres             |,4-  ) )-,_. ,\ (  `'-'
http://www.cfcl.com/~vlb      '---''(_/--'  `-'\_)
P.O. Box 1269 San Bruno, CA  94066

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch