Article View: uk.comp.os.linux
Article #608Re: Sysread/seek on Linux
From: 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
Technical Details
Message-ID:
<7tt6qt$80h$1@pegasus.csx.cam.ac.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<f51n1tpamof.fsf@cogsci.ed.ac.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1107b1,e66fc27742978826 X-Google-Attributes: gid1107b1,public X-Google-Thread: 10d8ad,e66fc27742978826 X-Google-Attributes: gid10d8ad,public From: pjb1008@cus.cam.ac.uk (Peter Benie) Subject: Re: Sysread/seek on Linux Date: 1999/10/11 Message-ID: <7tt6qt$80h$1@pegasus.csx.cam.ac.uk> X-Deja-AN: 535457263 References: <f51n1tpamof.fsf@cogsci.ed.ac.uk> Organization: High Performance Computing Facility Newsgroups: uk.comp.os.linux,ed.linux