From 43abbfb6e6af8d5a8d45aeabcf407fb48ede5e43 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 3 May 2024 10:43:31 +0800 Subject: [PATCH] Prevent reporting of crashes when Emacs is restarted on Android * src/emacs.c (Fkill_emacs): Ignore SIGBUS and SIGSGEV immediately before calling exit. (cherry picked from commit 6171a9a628fb71b172598c7d7bbea8448ee251d6) --- src/emacs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/emacs.c b/src/emacs.c index 1cb1e70ac65..7431cef274d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2999,6 +2999,21 @@ killed. */ #ifdef HAVE_NATIVE_COMP eln_load_path_final_clean_up (); #endif +#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY + if (android_init_gui) + { + /* Calls to exit may be followed by illegal accesses from + toolkit-managed threads as the thread group is destroyed, which + are inconsequential when the process is being terminated, but + which must be suppressed to inhibit reporting of superfluous + crashes by the system. + + Execution won't return to Emacs whatever the value of RESTART, + as `android_restart_emacs' will only ever abort or succeed. */ + signal (SIGBUS, SIG_IGN); + signal (SIGSEGV, SIG_IGN); + } +#endif /* HAVE_ANDROID && !ANDROID_STUBIFY */ if (!NILP (restart)) { -- 2.39.5