about summary refs log tree commit diff
path: root/manual
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2024-09-06 20:38:23 +0000
committerJoseph Myers <josmyers@redhat.com>2024-09-06 20:38:23 +0000
commita2509a8bc955988f01f389a1cf74db3a9da42409 (patch)
tree826087cf15e24b07bc4d44b4a32dcf37c330805f /manual
parent7d6e30b4b4e83429cc77222d4fe4d5e8843d8e2b (diff)
downloadglibc-a2509a8bc955988f01f389a1cf74db3a9da42409.tar.gz
glibc-a2509a8bc955988f01f389a1cf74db3a9da42409.tar.xz
glibc-a2509a8bc955988f01f389a1cf74db3a9da42409.zip
Document limitations on streams passed to freopen
As recently discussed, document that freopen does not work with
streams opened with functions such as popen, fmemopen, open_memstream
or fopencookie.  I've filed
<https://austingroupbugs.net/view.php?id=1855> to clarify this issue
in POSIX.

Tested with "make info" and "make html".
Diffstat (limited to 'manual')
-rw-r--r--manual/stdio.texi8
1 files changed, 8 insertions, 0 deletions
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 29888a361f..8590ae955a 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -330,6 +330,14 @@ this ability, so using @code{freopen} is more portable.
 When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} on a
 32 bit machine this function is in fact @code{freopen64} since the LFS
 interface replaces transparently the old interface.
+
+@Theglibc{} only supports use of @code{freopen} on streams opened with
+@code{fopen} or @code{fopen64} and on the original values of the
+standard streams @code{stdin}, @code{stdout}, and @code{stderr}; such
+a stream may be reopened multiple times with @code{freopen}.  If it is
+called on another kind of stream (opened with functions such as
+@code{popen}, @code{fmemopen}, @code{open_memstream}, and
+@code{fopencookie}), @code{freopen} fails and returns a null pointer.
 @end deftypefun
 
 @deftypefun {FILE *} freopen64 (const char *@var{filename}, const char *@var{opentype}, FILE *@var{stream})