fopen.3: Describe freopen() behavior for NULL pathname argument

See https://bugzilla.kernel.org/show_bug.cgi?id=191261

Reported-by: Helmut Eller <eller.helmut@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-01-05 15:45:01 +13:00
parent a8250b9163
commit 7eed8a8f10
1 changed files with 22 additions and 0 deletions

View File

@ -202,6 +202,28 @@ The
argument is used just as in the
.BR fopen ()
function.
If the
.I path
argument is a null pointer,
.BR freopen ()
changes the mode of the stream to that specified in
.IR mode ;
that is,
.BR freopen ()
reopens the pathname that is associated with the stream.
The specification for this behavior was added in the C99 standard, which says:
.RS
In this case,
the file descriptor associated with the stream need not be closed
if the call to
.BR freopen ()
succeeds.
It is implementation-defined which changes of mode are permitted (if any),
and under what circumstances.
.RE
.PP
The primary use of the
.BR freopen ()
function is to change the file associated with a standard text stream