bug-coreutils
[Top][All Lists]
Advanced

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

Re: mktemp write failure


From: Jim Meyering
Subject: Re: mktemp write failure
Date: Thu, 05 Nov 2009 19:07:20 +0100

Eric Blake wrote:
> 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!

It's not just cygwin
Also on fedora 12 and rawhide:

  $ ./mktemp -q >&-; echo $?
  0

> 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.




reply via email to

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