diff options
author | Jim Meyering <jim@meyering.net> | 2000-05-20 22:06:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-05-20 22:06:38 +0000 |
commit | 24f2bd8c9f62409ef7d7c919c9a53f438ee991cb (patch) | |
tree | 0d30aa82a2c6c12ab2224c5ecffb9ded6a11caaa /src/head.c | |
parent | ac8180336348bee878584b013d71f84e5d047f21 (diff) | |
download | coreutils-24f2bd8c9f62409ef7d7c919c9a53f438ee991cb.tar.gz coreutils-24f2bd8c9f62409ef7d7c919c9a53f438ee991cb.tar.bz2 coreutils-24f2bd8c9f62409ef7d7c919c9a53f438ee991cb.zip |
Arrange to call close_stdout upon exit. Don't close stdout explicitly.
Diffstat (limited to 'src/head.c')
-rw-r--r-- | src/head.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/head.c b/src/head.c index 70f3b5598..44e0ab294 100644 --- a/src/head.c +++ b/src/head.c @@ -30,6 +30,7 @@ #include <getopt.h> #include <sys/types.h> #include "system.h" +#include "closeout.h" #include "error.h" #include "xstrtol.h" #include "safe-read.h" @@ -191,6 +192,7 @@ head_file (const char *filename, uintmax_t n_units, int count_lines) filename = _("standard input"); if (print_headers) write_header (filename); + /* FIXME: use STDIN_FILENO, not `0' */ return head (filename, 0, n_units, count_lines); } else @@ -263,6 +265,8 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); + atexit (close_stdout); + have_read_stdin = 0; print_headers = 0; @@ -383,8 +387,6 @@ main (int argc, char **argv) if (have_read_stdin && close (0) < 0) error (EXIT_FAILURE, errno, "-"); - if (fclose (stdout) == EOF) - error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } |