From: Paul Eggert Date: Sat, 22 Sep 2012 07:34:52 +0000 (-0700) Subject: * emacs.c (shut_down_emacs): Don't assume stderr is buffered, X-Git-Tag: emacs-24.2.90~266 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=01108e3f4567db222a7e6e2ed9c484506b491dba;p=emacs.git * emacs.c (shut_down_emacs): Don't assume stderr is buffered, or that fprintf is async-signal-safe. POSIX doesn't require either assumption. --- diff --git a/src/ChangeLog b/src/ChangeLog index 439b5c06e27..847e065e1c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2012-09-22 Paul Eggert + + * emacs.c (shut_down_emacs): Don't assume stderr is buffered, + or that fprintf is async-signal-safe. POSIX doesn't require + either assumption. + 2012-09-22 Chong Yidong * buffer.c (Fset_buffer_modified_p): Handle indirect buffers diff --git a/src/emacs.c b/src/emacs.c index d4b52ab64ea..a483f3848cf 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -27,6 +27,8 @@ along with GNU Emacs. If not, see . */ #include #include +#include + #include "lisp.h" #ifdef HAVE_WINDOW_SYSTEM @@ -2012,7 +2014,12 @@ shut_down_emacs (int sig, Lisp_Object stuff) { reset_all_sys_modes (); if (sig && sig != SIGTERM) - fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig)); + { + char buf[100]; + int buflen = snprintf (buf, sizeof buf, "Fatal error %d: %s", + sig, strsignal (sig)); + ignore_value (write (STDERR_FILENO, buf, buflen)); + } } } #else