From 948e6609b11b0203d6e1d0fdfdcc23b8538f3e98 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 7 Mar 2021 16:31:35 +0200 Subject: [PATCH] Avoid aborts in native-comp subprocesses when exiting Emacs on Windows * src/w32.c (shutdown_handler): Clear the message stack when being shut down in noninteractive mode, to avoid aborting in shut_down_emacs when a native-compilation subprocess is killed because the parent Emacs exits. --- src/w32.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/w32.c b/src/w32.c index 7ce907d0adb..14b8b11da00 100644 --- a/src/w32.c +++ b/src/w32.c @@ -10447,6 +10447,13 @@ shutdown_handler (DWORD type) || type == CTRL_LOGOFF_EVENT /* User logs off. */ || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */ { + /* If we are being shut down in noninteractive mode, we don't + care about the message stack, so clear it to avoid abort in + shut_down_emacs. This happens when an noninteractive Emacs + is invoked as a subprocess of Emacs, and the parent wants to + kill us, e.g. because it's about to exit. */ + if (noninteractive) + clear_message_stack (); /* Shut down cleanly, making sure autosave files are up to date. */ shut_down_emacs (0, Qnil); } -- 2.39.2