public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Note in fmemopen() that no file descriptor is allocated
       [not found]     ` <9c3275a90904160726i68a4c1f6u8173f72365042e65-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-04-16 14:58       ` Petr Baudis
       [not found]         ` <20090416145804.GZ8940-DDGJ70k9y3lX+M3pkMnKjw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Baudis @ 2009-04-16 14:58 UTC (permalink / raw)
  To: Alexander Lamaison, mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w
  Cc: libc-help-9JcytcrH/bA+uJoB2kUjGw,
	linux-man-u79uwXL29TY76Z2rM5mHXA

Alexander Lamaison <awl03-CezfXpuMXD6Fxr2TtlUqVg@public.gmane.org> 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-AlSwsSmVLrQ@public.gmane.org>

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Note in fmemopen() that no file descriptor is allocated
       [not found]         ` <20090416145804.GZ8940-DDGJ70k9y3lX+M3pkMnKjw@public.gmane.org>
@ 2009-04-21  4:19           ` Michael Kerrisk
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk @ 2009-04-21  4:19 UTC (permalink / raw)
  To: Petr Baudis
  Cc: Alexander Lamaison, libc-help-9JcytcrH/bA+uJoB2kUjGw,
	linux-man-u79uwXL29TY76Z2rM5mHXA

Hi Petr

On Fri, Apr 17, 2009 at 2:58 AM, Petr Baudis <pasky-AlSwsSmVLrQ@public.gmane.org> wrote:
> Alexander Lamaison <awl03-CezfXpuMXD6Fxr2TtlUqVg@public.gmane.org> 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.

Thanks -- I applied that as a separate change.

> Signed-off-by: Petr Baudis <pasky-AlSwsSmVLrQ@public.gmane.org>
>
> 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 .

I shortened and reworded your text somewhat, since I don't think we
need to mention details about fstat():

[[
.SH NOTES
There is no file descriptor associated with the file stream
returned by these functions
(i.e.,
.BR fileno (3)
will return an error if called on the returned stream).
]]

The changes will be in man-pages-3.22.

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-21  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <9c3275a90904151642n7a13cf06w6e1834b849d37f1a@mail.gmail.com>
     [not found] ` <20090416082503.GH21271@machine.or.cz>
     [not found]   ` <9c3275a90904160726i68a4c1f6u8173f72365042e65@mail.gmail.com>
     [not found]     ` <9c3275a90904160726i68a4c1f6u8173f72365042e65-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-04-16 14:58       ` [PATCH] Note in fmemopen() that no file descriptor is allocated Petr Baudis
     [not found]         ` <20090416145804.GZ8940-DDGJ70k9y3lX+M3pkMnKjw@public.gmane.org>
2009-04-21  4:19           ` Michael Kerrisk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox