From: Jim Meyering Date: Thu, 5 Nov 2009 15:26:19 +0000 (+0100) Subject: mktemp: don't try to close stdout twice X-Git-Tag: v8.1~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22e4276ed1b3ef67446e8f003b7bcf7753cbc9bc;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/src/mktemp.c b/src/mktemp.c index f60e824869..980ec39306 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -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);