mktemp: don't try to close stdout twice

* src/mktemp.c (main): Rather than calling close_stream (which would
make atexit-called close_stdout try to close it a second time),
check for write failure via ferror and fflush.
This commit is contained in:
Jim Meyering committed 2009-11-05 16:32:52 +01:00
1 parent 25d2460ae3
commit 22e4276ed1
1 file changed
+1 -1
+1 -1
View File
@@ -325,7 +325,7 @@ main (int argc, char **argv)
puts (dest_name);
/* If we created a file, but then failed to output the file
name, we should clean up the mess before failing. */
if (!dry_run && close_stream (stdout))
if (!dry_run && (ferror (stdout) || fflush (stdout) != 0))
{
int saved_errno = errno;
remove (dest_name);