[net.unix-wizards] open

chris.umcp-cs@Udel-Relay@sri-unix (11/19/82)

From:     Chris Torek <chris.umcp-cs@Udel-Relay>
Date:     15 Nov 82 01:41:50 EST  (Mon)
I'm almost sure that's documented somewhere, but I can't remember where.
I think it's in the "beginner's guide to unix" but that's just a guess.
Actually, it's kinda neat because even if someone removes the directory
you're working in the null name still gets it opened (since it bypasses
all the other stuff in nami()).

Robert_Toxen%anvil.UUCP@harvard.harvard.edu (04/15/86)

> 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
============================