bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mktemp write failure (was: temp file suffixes: mktemp DWIM)


From: Eric Blake
Subject: mktemp write failure (was: temp file suffixes: mktemp DWIM)
Date: Thu, 5 Nov 2009 16:57:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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







reply via email to

[Prev in Thread] Current Thread [Next in Thread]