]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
fopen.3: Explain BSD vs glibc "a+" difference
authorenh <enh@google.com>
Wed, 10 Apr 2019 19:30:24 +0000 (12:30 -0700)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sun, 14 Apr 2019 17:12:34 +0000 (19:12 +0200)
Where is the initial read position for an "a+" stream?

POSIX leaves this unspecified. Most BSD man pages are silent, and MacOS
has the ambiguous "The stream is positioned at the end of the file", not
differentiating between reads and writes other than to say that fseek(3)
does not affect writes. glibc's documentation explicitly specifies that
the initial read position is the beginning of the file.

My new wording is based on the BSD implementations, so you may prefer
to replace the non-glibc section with "unspecified", or indeed remove
all claims about the initial read position.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/fopen.3

index a0f564c394d406c62a8d5c004059cae56a929da3..5f4abb8eae89f175e3f1f87d8482c8157e4b2be1 100644 (file)
@@ -100,8 +100,10 @@ The stream is positioned at the end of the file.
 .B a+
 Open for reading and appending (writing at end of file).
 The file is created if it does not exist.
-The initial file position for reading is at the beginning of the file,
-but output is always appended to the end of the file.
+Output is always appended to the end of the file.
+For glibc, the initial file position for reading is at
+the beginning of the file, but for Android/BSD/MacOS, the
+initial file position for reading is the end of the file.
 .PP
 The
 .I mode