On 08/20/2010 02:12 PM, Paul Eggert wrote: > On 08/20/10 15:38, Eric Blake wrote: >> freopen(NULL,"wb",stdout) has implementation-defined effects > > That's true for the C standard, but POSIX is reasonably specific > about the fact that changing a file's mode from "w" to "wb" is > not a change at all,
Maybe so, but POSIX is still quite clear that passing a NULL pointer instead of a filename is implementation defined: http://www.opengroup.org/onlinepubs/9699919799/functions/freopen.html If filename is a null pointer, the freopen() function shall attempt to change the mode of the stream to that specified by mode, as if the name of the file currently associated with the stream had been used. In this case, the file descriptor associated with the stream need not be closed if the call to freopen() succeeds. It is implementation-defined which changes of mode are permitted (if any), and under what circumstances. > and that no file descriptors need to be > opened, duped, or allocated in order to perform this non-change. None need be opened, but likewise the implementation is not forbidden from forbidding all mode changes in all cases, in which case the implementation is free to document that passing a NULL first argument will never succeed. -- Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
