Bug 191261

Summary: freopen with NULL as path argument
Product: Documentation Reporter: Helmut Eller (eller.helmut)
Component: man-pagesAssignee: documentation_man-pages (documentation_man-pages)
Status: RESOLVED CODE_FIX    
Severity: normal CC: mtk.manpages
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Helmut Eller 2016-12-27 18:44:18 UTC
The man page for freopen should describe the behavior if the "path" argument is NULL, i.e. that if "path" is NULL then freopen tries to reopen the file associated with the "stream" argument.  I think this was added in C99. If it doesn't work in C89 then it would also be good to mention that.
Comment 1 Michael Kerrisk 2017-01-05 02:49:08 UTC
Hello Helmut,

I added the following text to the page:

       If the path argument is a null pointer, freopen() changes the mode
       of the stream to  that  specified  in  mode;  that  is,  freopen()
       reopens  the  pathname  that  is  associated with the stream.  The
       specification for this behavior was added  in  the  C99  standard,
       which says:

              In  this  case,  the  file  descriptor  associated with the
              stream need not be closed if the  call  to  freopen()  suc‐
              ceeds.   It is implementation-defined which changes of mode
              are permitted (if any), and under what circumstances.

I'll close this bug now. Please reopen if you think anything more is required.

Cheers,

Michael