(main): Use close_stdout via atexit.
authorJim Meyering <jim@meyering.net>
Fri, 18 Jul 2003 08:53:05 +0000 (08:53 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 18 Jul 2003 08:53:05 +0000 (08:53 +0000)
Now `sort --version' and `sort --help' fail, as they should
when their output is redirected to /dev/full.

src/sort.c

index cb9b619..2d90724 100644 (file)
 #include <stdio.h>
 #include <assert.h>
 #include "system.h"
-#include "long-options.h"
+#include "closeout.h"
 #include "error.h"
 #include "exitfail.h"
 #include "hard-locale.h"
 #include "inttostr.h"
+#include "long-options.h"
 #include "physmem.h"
 #include "posixver.h"
 #include "stdio-safer.h"
@@ -2182,6 +2183,9 @@ main (int argc, char **argv)
 
   atexit (cleanup);
 
+  atexit (close_stdout);
+  close_stdout_set_status (SORT_FAILURE);
+
   hard_LC_COLLATE = hard_locale (LC_COLLATE);
 #if HAVE_NL_LANGINFO
   hard_LC_TIME = hard_locale (LC_TIME);