🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #86

Re: does "always append" apply to "a+" mode?

#86
From: Rahul Dhesi
Date: Tue, 04 Aug 1992 22:23
29 lines
1682 bytes
In <13851@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A.
O'Keefe) writes:

>It has never been clear to me what the model is for "a" mode.

The only thing that stdio's "a" mode can guarantee is that no data
written to the file will be lost by being overwritten by some other
process.  But because some implementations are broken, even this
guarantee is meaningless.  So what very portable code should do is to
lock the file against concurrent updates, then seek to the end, then
write, then fflush.  This is what my code does, when I need to use stdio
rather than the write() system call.

SunOS 4.1.1 is weird.  The fopen() man page claims correct append
behavior only for the System V environment:

   SYSTEM V DESCRIPTION
        When a file is opened for append (that is, when type is a or
        a+), it is impossible to overwrite information already in
        the file.  fseek() may be used to reposition the file
        pointer to any position in the file, but when output is
        written to the file, the current file pointer is disre-
        garded.

I don't know why Sun doesn't do the same for the BSD environment, which
is the default unless a user puts /usr/5bin very early in the path.
-- 
Rahul Dhesi <dhesi@cirrus.com>
also: dhesi@rahul.net
Technical Details
Message-ID: <1992Aug4.222333.21567@cirrus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!indetech!cirrus!dhesi
References: <24992@dog.ee.lbl.gov> <13851@goanna.cs.rmit.oz.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!indetech!cirrus!dhesi
From: dhesi@cirrus.com (Rahul Dhesi)
Subject: Re: does "always append" apply to "a+" mode?
Message-ID: <1992Aug4.222333.21567@cirrus.com>
Sender: news@cirrus.com
Organization: Cirrus Logic Inc.
References: <24992@dog.ee.lbl.gov> <13851@goanna.cs.rmit.oz.au>
Date: Tue, 4 Aug 1992 22:23:33 GMT
Lines: 29