diff options
author | Jim Meyering <jim@meyering.net> | 2005-04-09 14:15:22 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-04-09 14:15:22 +0000 |
commit | e115c60a2a77967e309f55b5e711474116c92883 (patch) | |
tree | 3662fd2cae807d4b69cb8ccc83f797d9a0c5eaf3 /src | |
parent | 58415b5d5d3e2fec7875fce5f39de8fba2201c59 (diff) | |
download | coreutils-e115c60a2a77967e309f55b5e711474116c92883.tar.xz |
(quit): Define with ATTRIBUTE_NORETURN.
Now that close_stdout closes standard output unconditionally,
these workarounds for dd and cat are no longer necessary.
(close_stdout_wrapper): Remove function.
(main): Call atexit with close_stdout, instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/dd.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -572,12 +572,16 @@ cleanup (void) if (close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, _("closing input file %s"), quote (input_file)); + + /* Don't remove this call to close, even though close_stdout + closes standard output. This close is necessary when cleanup + is called as part of a signal handler. */ if (close (STDOUT_FILENO) < 0) error (EXIT_FAILURE, errno, _("closing output file %s"), quote (output_file)); } -static inline void +static inline void ATTRIBUTE_NORETURN quit (int code) { cleanup (); @@ -1561,17 +1565,6 @@ dd_copy (void) return exit_status; } -/* This is gross, but necessary, because of the way close_stdout - works and because this program closes STDOUT_FILENO directly. */ -static void (*closeout_func) (void) = close_stdout; - -static void -close_stdout_wrapper (void) -{ - if (closeout_func) - (*closeout_func) (); -} - int main (int argc, char **argv) { @@ -1586,16 +1579,13 @@ main (int argc, char **argv) textdomain (PACKAGE); /* Arrange to close stdout if parse_long_options exits. */ - atexit (close_stdout_wrapper); + atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); - /* Don't close stdout on exit from here on. */ - closeout_func = NULL; - /* Initialize translation table to identity translation. */ for (i = 0; i < 256; i++) trans_table[i] = i; |