Arrange to call close_stdout upon exit. Don't close stdout explicitly.
authorJim Meyering <jim@meyering.net>
Sat, 20 May 2000 22:04:16 +0000 (22:04 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 20 May 2000 22:04:16 +0000 (22:04 +0000)
src/comm.c

index 5020902..eb5d189 100644 (file)
@@ -1,5 +1,5 @@
 /* comm -- compare two sorted files line by line.
-   Copyright (C) 86, 90, 91, 1995-1999 Free Software Foundation, Inc.
+   Copyright (C) 86, 90, 91, 1995-2000 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include "system.h"
+#include "closeout.h"
 #include "linebuffer.h"
 #include "error.h"
 #include "hard-locale.h"
@@ -215,11 +216,6 @@ compare_files (char **infiles)
          ret = 1;
        }
     }
-  if (ferror (stdout) || fclose (stdout) == EOF)
-    {
-      error (0, errno, _("write error"));
-      ret = 1;
-    }
   return ret;
 }
 
@@ -233,6 +229,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
 #ifdef ENABLE_NLS
   hard_LC_COLLATE = hard_locale (LC_COLLATE);
 #endif