From 22e4276ed1b3ef67446e8f003b7bcf7753cbc9bc Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 5 Nov 2009 16:26:19 +0100 Subject: 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. --- src/mktemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mktemp.c b/src/mktemp.c index f60e82486..980ec3930 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); -- cgit v1.2.3-70-g09d2