Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-adm!brl-smoke!smoke!es!Robert_Toxen%anvil.UUCP@harvard.harvard.edu From: Robert_Toxen%anvil.UUCP@harvard.harvard.edu Newsgroups: net.unix-wizards Subject: open() with O_APPEND Message-ID: <26@brl-smoke.ARPA> Date: Tue, 15-Apr-86 15:59:06 EST Article-I.D.: brl-smok.26 Posted: Tue Apr 15 15:59:06 1986 Date-Received: Fri, 18-Apr-86 04:35:28 EST Sender: news@brl-smoke.ARPA Lines: 28 > From: anvil!harvard!csnet-relay.arpa!moi%brandeis.csnet > Subject: a question on open() and lseek() > > 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 ); > > I saw the sequence used in a section of code where the single call would make > sense. > > Moises Lejter moi%brandeis@csnet-relay.arpa The former sequence has no advantage over the latter. The O_APPEND is fairly new (came out in System III) and so old programs (and old programmers) use the former. The latter has the advantage in that it is guaranteed to work even if two or more programs are writing to the same file. I used this to advantage to speed up UUCP by eliminating the need to lock the LOGFILE & SYSLOG files. Bob Toxen Stratus Computer {ucbvax!ihnp4,harvard}!anvil!bob ============================