Path: utzoo!attcan!uunet!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: fopen ( ..., "a" ) --- how does the "a" work? Message-ID: <11794@smoke.BRL.MIL> Date: 12 Dec 89 02:48:20 GMT References: <31276@iuvax.cs.indiana.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 23 In article <31276@iuvax.cs.indiana.edu> bobmon@iuvax.cs.indiana.edu (RAMontante) writes: >gwyn@brl.arpa (Doug Gwyn) <11775@smoke.BRL.MIL> : >-On a single-user non-multitasking system, a better implementation >-[of append] would >-be to seek to the end only on the initial open, not for each write. >Is the process forbidden from doing an lseek, or are you allowing the >programmer to reposition somewhere else in the file? What is the >semantics of the append behavior? You must mean fseek(), as use of lseek() in conjunction with a stdio stream can break stdio operation. fseek() on an "a" mode stream could report failure (or, to be fancy, it could succeed if the f.p.i. wouldn't be changed by the seek). However, the story for an "a+" mode stream is different, because so far as I can determine reads from the stream can be initiated anywhere by preceding them with fseek() calls, and only writes are required to jump to the end of the file. Whether or not seek before write would be necessary depends on how much state information is maintained for the stream by the stdio implementation.