From e115c60a2a77967e309f55b5e711474116c92883 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 9 Apr 2005 14:15:22 +0000 Subject: [PATCH] (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. --- src/dd.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/dd.c b/src/dd.c index 6083a73c90..27ac661b27 100644 --- a/src/dd.c +++ b/src/dd.c @@ -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; -- 2.47.3