summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-12-14 01:39:46 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-12-14 01:39:46 +0000
commitf5e1bca49d27e39a24026b903287ad47ae66c53c (patch)
treeae7dda7c200194a75186cd3a4833e7c8e4b4462c
parent3463531cd0ab7a779ef9327c55eaa32b63907b7e (diff)
downloadcoreutils-f5e1bca49d27e39a24026b903287ad47ae66c53c.tar.xz
(main): Check for close (STDOUT_FILENO) failure.
-rw-r--r--src/cat.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cat.c b/src/cat.c
index 4012d8ffc..307a51644 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -555,7 +555,9 @@ main (int argc, char **argv)
textdomain (PACKAGE);
/* Arrange to close stdout if we exit via the
- case_GETOPT_HELP_CHAR or case_GETOPT_VERSION_CHAR code. */
+ case_GETOPT_HELP_CHAR or case_GETOPT_VERSION_CHAR code.
+ Normally STDOUT_FILENO is used rather than stdout, so
+ close_stdout does nothing. */
atexit (close_stdout);
/* Parse command line options. */
@@ -766,5 +768,8 @@ main (int argc, char **argv)
if (have_read_stdin && close (STDIN_FILENO) < 0)
error (EXIT_FAILURE, errno, _("closing standard input"));
+ if (close (STDOUT_FILENO) != 0)
+ error (EXIT_FAILURE, errno, _("write error"));
+
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}