From: Paul Eggert Date: Sun, 4 Nov 2012 17:29:52 +0000 (-0800) Subject: Fix data-loss with --version. X-Git-Tag: emacs-24.3.90~173^2~9^2~161 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=76abf5e5a55899a0b3f8851fce7406858978e9a6;p=emacs.git Fix data-loss with --version. * emacs.c (close_output_streams): Use strerror, not emacs_strerror, as we can't assume that emacs_strerror is initialized, and strerror is good enough here. (main): Invoke atexit earlier, to catch earlier instances of sending data to stdout and exiting, e.g., "emacs --version >/dev/full". Fixes: debbugs:9574 --- diff --git a/src/ChangeLog b/src/ChangeLog index b30b2163435..3356c9874cc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-11-04 Paul Eggert + + Fix data-loss with --version (Bug#9574). + * emacs.c (close_output_streams): Use strerror, not emacs_strerror, + as we can't assume that emacs_strerror is initialized, and strerror + is good enough here. + (main): Invoke atexit earlier, to catch earlier instances of + sending data to stdout and exiting, e.g., "emacs --version >/dev/full". + 2012-11-04 Michael Marchionna * nsterm.m: Add NSClearLineFunctionKey and keypad keys (Bug#8680). diff --git a/src/emacs.c b/src/emacs.c index 6588bcd78b1..061c4b4b131 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -684,7 +684,7 @@ close_output_streams (void) if (close_stream (stdout) != 0) { fprintf (stderr, "Write error to standard output: %s\n", - emacs_strerror (errno)); + strerror (errno)); fflush (stderr); _exit (EXIT_FAILURE); } @@ -748,6 +748,8 @@ main (int argc, char **argv) unexec_init_emacs_zone (); #endif + atexit (close_output_streams); + sort_args (argc, argv); argc = 0; while (argv[argc]) argc++; @@ -907,8 +909,6 @@ main (int argc, char **argv) if (do_initial_setlocale) setlocale (LC_ALL, ""); - atexit (close_output_streams); - inhibit_window_system = 0; /* Handle the -t switch, which specifies filename to use as terminal. */