]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
mktemp: don't try to close stdout twice
authorJim Meyering <meyering@redhat.com>
Thu, 5 Nov 2009 15:26:19 +0000 (16:26 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 5 Nov 2009 15:32:52 +0000 (16:32 +0100)
* 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.

src/mktemp.c

index f60e82486917002bce9751965c103d42d6bfa074..980ec3930678a79207eba48c949ccf50441bd256 100644 (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);