emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 190a685: Don't abort when terminated by SIGINT in -batch


From: Eli Zaretskii
Subject: master 190a685: Don't abort when terminated by SIGINT in -batch
Date: Fri, 4 Dec 2020 09:49:21 -0500 (EST)

branch: master
commit 190a6853708ab22072437f6ebd93beb3ec1a9ce6
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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.
---
 src/emacs.c | 9 ++++++++-
 src/lisp.h  | 1 +
 src/xdisp.c | 9 +++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index 172e460..d1b010e 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 a95913c..9901f80 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 76ef420..ed1d476 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.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]