fopen ( ..., "a" ) --- how does the "a" work?
6600pete at hub.UUCP
6600pete at hub.UUCP
Thu Dec 7 20:52:58 AEST 1989
>From article <895 at hsi86.hsi.UUCP-, by stevens at hsi.UUCP (Richard Stevens):
- In article <3250 at hub.UUCP-, 6600pete at hub.UUCP writes:
-- When one opens a file under *most* flavors of UN*X
-- with fopen ( ..., "a" ), the file mark is supposed to be moved to EOF
-- before every write. Now, how is this done? Are there two system calls,
-- one to move the file mark and one to do the write, or is there one
-- system call, "append"?
-
- With System V Release 2, [ there is one system call ].
- I suspect the later release of System V also do this.
-
- Interesting, however, is that the 4.3BSD source differs. It does
- an lseek to the EOF when fopen is called, and that's it. 4.3 does
- have an O_APPEND option to open, but it doesn't appear to be used.
>From article <MEISSNER.89Dec6215032 at tiktok.rtp.dg.com-, by meissner at dg-rtp.dg.com
(Michael Meissner):
- On a filesystem local to the machine, [ the append ]
- is done atomically with the write call. I'm not sure whether this is
- guaranteed to be atomic under NFS, but I suspect not, particularly if
- the NFS server is not a UNIX system (such as a VAX running VMS or IBM
- mainframe).
- My version 7 manual does not list any flags for open, and the fopen
- man page does not make any promises about ruber-banding the file
- position to the end of the file.
Perhaps the best way to do it, then, is to call open() with O_APPEND,
then pass the handle to fdopen()? What does anyone think?
-------------------------------------------------------------------------------
Pete Gontier : InterNet: 6600pete at ucsbuxa.ucsb.edu, BitNet: 6600pete at ucsbuxa
Editor, Macker : Online Macintosh Programming Journal; mail for subscription
Hire this kid : Mac, DOS, C, Pascal, asm, excellent communication skills
More information about the Comp.unix.questions
mailing list