#include <stdio.h>
#include <assert.h>
#include "system.h"
+#include "closeout.h"
#include "long-options.h"
#include "error.h"
#include "hard-locale.h"
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ close_stdout_set_status (SORT_FAILURE);
+ atexit (close_stdout);
+
#ifdef ENABLE_NLS
hard_LC_COLLATE = hard_locale (LC_COLLATE);
else
outfile = argv[++i];
}
+ close_stdout_set_file_name (outfile);
goto outer;
case 's':
stable = 1;
struct stat outstat;
if (stat (outfile, &outstat) == 0)
{
+ /* FIXME: warn about this */
/* The following code prevents a race condition when
people use the brain dead shell programming idiom:
cat file | sort -o file
if (have_read_stdin && fclose (stdin) == EOF)
error (SORT_FAILURE, errno, "%s", outfile);
- if (ferror (stdout) || fclose (stdout) == EOF)
- error (SORT_FAILURE, errno, _("%s: write error"), outfile);
exit (EXIT_SUCCESS);
}