From: Eli Zaretskii Date: Fri, 4 Dec 2020 14:47:49 +0000 (+0200) Subject: Don't abort when terminated by SIGINT in -batch X-Git-Tag: emacs-28.0.90~4927 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=190a6853708ab22072437f6ebd93beb3ec1a9ce6;p=emacs.git Don't abort when terminated by SIGINT in -batch * src/xdisp.c (clear_message_stack): New function. * src/emacs.c (terminate_due_to_signal): Call clear_message_stack when we are being shut down by SIGINT under -batch. * src/lisp.h (clear_message_stack): Add prototype. --- diff --git a/src/emacs.c b/src/emacs.c index 172e4607694..d1b010ec7fe 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -386,7 +386,14 @@ terminate_due_to_signal (int sig, int backtrace_limit) totally_unblock_input (); if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) - Fkill_emacs (make_fixnum (sig)); + { + /* Avoid abort in shut_down_emacs if we were interrupted + by SIGINT in noninteractive usage, as in that case we + don't care about the message stack. */ + if (sig == SIGINT && noninteractive) + clear_message_stack (); + Fkill_emacs (make_fixnum (sig)); + } shut_down_emacs (sig, Qnil); emacs_backtrace (backtrace_limit); diff --git a/src/lisp.h b/src/lisp.h index a95913c4efe..9901f80b51c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3715,6 +3715,7 @@ extern Lisp_Object echo_area_buffer[2]; extern void add_to_log (char const *, ...); extern void vadd_to_log (char const *, va_list); extern void check_message_stack (void); +extern void clear_message_stack (void); extern void setup_echo_area_for_printing (bool); extern bool push_message (void); extern void pop_message_unwind (void); diff --git a/src/xdisp.c b/src/xdisp.c index 76ef420a364..ed1d4761b95 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11929,8 +11929,8 @@ pop_message_unwind (void) /* Check that Vmessage_stack is nil. Called from emacs.c when Emacs - exits. If the stack is not empty, we have a missing pop_message - somewhere. */ + exits. If the stack is not empty, we have a missing + pop_message_unwind somewhere. */ void check_message_stack (void) @@ -11939,6 +11939,11 @@ check_message_stack (void) emacs_abort (); } +void +clear_message_stack (void) +{ + Vmessage_stack = Qnil; +} /* Truncate to NCHARS what will be displayed in the echo area the next time we display it---but don't redisplay it now. */