Eric Blake wrote: > Eric Blake <ebb9 <at> byu.net> writes: > >> This currently gives exit status 1, because the atexit() handler recognizes >> failure to print the file name to stdout, but leaves the temporary file >> around. Should we go ahead and manually flush/close stdout, rather than >> relying on close_stdout, so that we can then remove the just-created file if > we >> detect write failure? That way, if we fail to inform the user what just got >> created, we are at least avoiding littering their file system with a random >> file. >> >> 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? > > From: Eric Blake <[email protected]> > Date: Wed, 4 Nov 2009 14:02:20 -0700 > Subject: [PATCH] mktemp: don't leave file behind on write failure > > * src/mktemp.c (main): Remove just-created file if stdout had > problems. > * bootstrap.conf (gnulib_modules): Add remove. > * tests/misc/close-stdout: Test it. > * NEWS: Document it.
With your fix-up, that's a fine fix. Thanks! I should catch up on your doc- and primary change tomorrow.
