Thread View: uk.comp.os.linux
3 messages
3 total messages
Started by Robert Inder
Mon, 11 Oct 1999 00:00
Sysread/seek on Linux
Author: Robert Inder
Date: Mon, 11 Oct 1999 00:00
Date: Mon, 11 Oct 1999 00:00
36 lines
1974 bytes
1974 bytes
I have been trying to port a Perl application that works on
Solaris and FreeBSD onto Linux (redhat 5.2).
The application uses sysread/syswrite and seek, and basically, it seems
that these things do not work: I can seek once and sysread or syswrite, but
thereafter &tell() aways returns 0, and seeks appear to have no effect.
Read and Print, on the other hand, behave correctly.
I have found a comment from somebody simply stating in passing that
sysread/syswrite are unusable in Perl on Linux, but I haven't been able to
find anything more specific.
What is the situation?
Is Linux Perl really fundamentally broken?
Or is there just something wrong with the 5.004 build that Red Hat supply
(both 5.004m4 and 5.004m7)
Should I be trying to re-write my application, or build Perl from scratch,
or what?
Can anyone shed any light?
Robert.
--
_ --------------------------------------------------------------------------
|_)obert Inder, (http://www.hcrc.ed.ac.uk/~robert/)
| \ Research Fellow, HCRC, (http://www.hcrc.ed.ac.uk/)
University of Edinburgh, 2, Buccleuch Place, Edinburgh EH8 9LW SCOTLAND
------------------------------------------------------------------------------
Best Viewed in Ebriated.
Re: Sysread/seek on Linux
Author: Peter Benie
Date: Mon, 11 Oct 1999 00:00
Date: Mon, 11 Oct 1999 00:00
26 lines
1754 bytes
1754 bytes
In article <f51n1tpamof.fsf@cogsci.ed.ac.uk>, Robert Inder <robert@cogsci.ed.ac.uk> wrote: > >The application uses sysread/syswrite and seek, and basically, it seems >that these things do not work: I can seek once and sysread or syswrite, but >thereafter &tell() aways returns 0, and seeks appear to have no effect. &tell maps onto ftell() which tells you where you are in a stdio stream. If you use sysread/syswrite (which map onto the Unix I/O primitives), it's unreasonable to expect tell to give you a meaningful answer. Even in circumstances where tell is defined, you cannot mix it with sysread/syswrite - consider what happens when you run your program on a system with multiple byte end-of-line markers. To get the equivalent of tell, use something like: use POSIX; $fileposition = sysseek HANDLE, 0, SEEK_CUR; In C, it is possible, with care, to resynchronise the stdio stream with Unix I/O; you can mix the two if you know what you're doing. Perl doesn't export the necessary primitives to the application layer to resynchronise an input stream so you should _never_ mix stdio with sysread. For an uncomplicated life, EITHER use sysread, syswrite and sysseek OR use read, write, print, and tell. Peter
Re: Sysread/seek on Linux
Author: Richard Kettlewell
Date: Mon, 11 Oct 1999 00:00
Date: Mon, 11 Oct 1999 00:00
13 lines
940 bytes
940 bytes
Robert Inder <robert@cogsci.ed.ac.uk> writes:
> Is Linux Perl really fundamentally broken?
No, your program is. Look for the `sysread' entry in `man perlfunc',
where it says:
It bypasses stdio, so mixing this with other kinds of reads,
print(), write(), seek(), or tell() can cause confusion because
stdio usually buffers data.
--
http://www.greenend.org.uk/rjk/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads