Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!qantel!ptsfa!ptsfb!rob From: rob@ptsfb.UUCP (Rob Bernardo) Newsgroups: net.unix-wizards Subject: Re: a question on open() and lseek() Message-ID: <352@ptsfb.UUCP> Date: Tue, 15-Apr-86 09:42:39 EST Article-I.D.: ptsfb.352 Posted: Tue Apr 15 09:42:39 1986 Date-Received: Fri, 18-Apr-86 04:05:59 EST References: <2594@brl-smoke.ARPA> Reply-To: rob@ptsfb.UUCP (Rob Bernardo) Organization: Pacific Bell, San Francisco Lines: 23 In article <2594@brl-smoke.ARPA> moi%brandeis.csnet@csnet-relay.arpa writes: > > The manual page for "open()" mentions that one of the flags one > can specify with the call is O_APPEND. It's supposed to request > that all "write()"s be appended to the end of the file. Is > there any reason to use the sequence: > f = open( file, O_WRONLY ); > lseek( f, 0, L_XTND ); > instead of the single call: > f = open( file, O_WRONLY | O_APPEND ); None that I can think of. You would have to so the lseek() call before every write() if there might be another process appending to the same file. And that could fail because between your lseek() and your write() your process might get swapped out and the other appending process might write at the end of the file; your write() would then overwrite that of the other process, rather than be at the end of the file. I've seen this happen where there was a common error log file for a set of related programs on a system where the O_APPEND flag was broken causing the implicit lseek to take place only after the open, but no before each write. Rob Bernardo, San Ramon, CA (415) 823-2417 {ihnp4|dual|qantel}!ptsfa!rob Pacific * Bell