From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA30669; Wed, 19 Mar 2003 19:48:46 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA30218 for ; Wed, 19 Mar 2003 19:48:45 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2JImjf01402 for ; Wed, 19 Mar 2003 19:48:45 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.8/1.01.28121999) with ESMTP id h2JImfqZ061782 for ; Wed, 19 Mar 2003 19:48:41 +0100 (CET) Received: from (george@localhost) by clipper.ens.fr (8.12.3/jb-1.1) Date: Wed, 19 Mar 2003 19:48:40 +0100 From: Nicolas George To: caml-list@inria.fr Subject: Re: [Caml-list] Unix.lseek versus Pervasives.pos Message-ID: <20030319184840.GA12900@clipper.ens.fr> Reply-To: caml-list@inria.fr References: <877kavryp3.fsf@cs.uga.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <877kavryp3.fsf@cs.uga.edu> User-Agent: Mutt/1.4 X-Spam: no; 0.00; caml-list:01 lseek:01 pervasives:01 nonidi:01 printf:01 unixlabels:01 strace:01 rdonly:01 largefile:01 unspecified:01 ecrit:01 nicolas:01 buf:01 unix:02 let:04 X-Attachments: type="application/pgp-signature" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --AhhlLboLdkugWU4S Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Le nonidi 29 vent=F4se, an CCXI, cashin@cs.uga.edu a =E9crit=A0: > Printf.printf "after reading %d chars: \"%s\", position is %d\n" > (UnixLabels.read fd ~buf ~pos:0 ~len:10) > buf > (UnixLabels.lseek fd 0 ~mode:Unix.SEEK_CUR) Use strace, and you'll see something like that=A0: open("main.ml", O_RDONLY|O_LARGEFILE) =3D 3 _llseek(3, 0, [0], SEEK_CUR) =3D 0 read(3, " let main", 10) =3D 10 write(1, "after reading 10 chars: \" let m"..., 1066) =3D 1066 So you can see that the lseek is done before the read. And indeed, your calls to read and lseek can occur in an unspecified order. I guess that if you write let len =3D UnixLabels.read ... in let pos =3D UnixLabels.lseek ... in Printf.printf ... you will get the right result. --AhhlLboLdkugWU4S Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (SunOS) iD8DBQE+eLuHsGPZlzblTJMRAthcAKCtWxDCkiX1MFEWrizrwSWH/X10+wCgpRlW W1RgXbjAmE8GMNH058nzHgE= =WI9B -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners