* emacs.c (shut_down_emacs): Don't assume stderr is buffered,

or that fprintf is async-signal-safe.  POSIX doesn't require
either assumption.
This commit is contained in:
Paul Eggert 2012-09-22 00:34:52 -07:00
parent 471333800d
commit 01108e3f45
2 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2012-09-22 Paul Eggert <eggert@cs.ucla.edu>
* 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 <cyd@gnu.org>
* buffer.c (Fset_buffer_modified_p): Handle indirect buffers

View file

@ -27,6 +27,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/file.h>
#include <unistd.h>
#include <ignore-value.h>
#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