Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: a question on open() and lseek() Message-ID: <891@umcp-cs.UUCP> Date: Sun, 13-Apr-86 22:35:56 EST Article-I.D.: umcp-cs.891 Posted: Sun Apr 13 22:35:56 1986 Date-Received: Sat, 19-Apr-86 14:00:49 EST References: <2594@brl-smoke.ARPA> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 21 In article <2594@brl-smoke.ARPA> moi%brandeis.csnet@csnet-relay.arpa writes: >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 ); There are two points to consider here. First, the latter call does not work in some Unix variants (notably V6, V7, and 4.1BSD). Second, the two are not equivalent! Indeed, this was, as far as I can tell, the major reason for creating `append mode' in the first place. The open/lseek sequence suffers from the `non-atomic system call' syndrome: multiple writers may well interfere with each other. When logging, for example, you are often uninterested in sequencing, but each new message should be appended to the log file; in append mode, the kernel guarantees that `simultaneous' writers will not overwrite each other's messages. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu