[PATCH] Note in fmemopen() that no file descriptor is allocated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Lamaison <awl03@xxxxxxxxxxxx> pointed out that this is
not obvious from the documentation, citing an example with passing
the FILE * handle to a function that tries to fstat() its fileno()
in order to determine the buffer size.

This also moves BUGS before EXAMPLE according to the recommended
section order.

Signed-off-by: Petr Baudis <pasky@xxxxxxx>

diff --git a/man3/fmemopen.3 b/man3/fmemopen.3
index 608e16f..3ed6930 100644
--- a/man3/fmemopen.3
+++ b/man3/fmemopen.3
@@ -173,6 +173,22 @@ POSIX.1-2008.
 These functions are not specified in POSIX.1-2001,
 and are not widely available on other systems.
 These functions are GNU extensions.
+.SH NOTES
+There is no valid file descriptor associated with
+the returned handle, therefore
+.BR fileno (3)
+will return a negative value.
+Thus, you e.g. cannot determine the buffer size using
+.I fstat(fileno(f), &stat)
+and looking at
+.IR stat.st_size .
+.SH BUGS
+In glibc before version 2.7, seeking past the end of a stream created by
+.BR open_memstream ()
+does not enlarge the buffer; instead the
+.BR fseek ()
+call fails, returning \-1.
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996
 .SH "EXAMPLE"
 The program below uses
 .BR fmemopen ()
@@ -236,13 +252,6 @@ main(int argc, char *argv[])
     exit(EXIT_SUCCESS);
 }
 .fi
-.SH BUGS
-In glibc before version 2.7, seeking past the end of a stream created by
-.BR open_memstream ()
-does not enlarge the buffer; instead the
-.BR fseek ()
-call fails, returning \-1.
-.\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996
 .SH "SEE ALSO"
 .BR fopen (3),
 .BR fopencookie (3),
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux