Eric Blake <ebb9 <at> byu.net> writes:
> > Fortunately, 'mktemp >&-' does not make the mistake of printing the just-
> > created file as the contents of that file, since we close the fd returned
by
> > mkstemp before printing anything.
>
> How about the following?
Phooey.
mktemp >&-
detects write error, but
mktemp -q >&-
does not! We are calling freopen(,stderr), and at least on cygwin, that ends
up changing(!) stderr's underlying fd from 2 to 1, so that the file name is
successfully printed to /dev/null. This is probably a bug in cygwin's stdio
implementation of freopen, so I need to check whether other libc's are affected
similarly. But is certainly seems like I will need to implement freopen_safer
in gnulib to guarantee that when reopening one of the std streams, that the new
fd is identical to the original. I'm working on a fix.
--
Eric Blake