From: Lars Ingebrigtsen Date: Mon, 18 Apr 2022 09:02:55 +0000 (+0200) Subject: Improve `restart-emacs' error reporting X-Git-Tag: emacs-29.0.90~1931^2~433 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9fc3b003730b90d88af11a31ea55c38fd733503b;p=emacs.git Improve `restart-emacs' error reporting * src/emacs.c (Fkill_emacs): Do better error reporting on restarting. --- diff --git a/src/emacs.c b/src/emacs.c index 6ef19561e0b..e65ed125b9d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2770,6 +2770,22 @@ killed. */ { int exit_code; +#ifndef WINDOWSNT + /* Do some checking before shutting down Emacs, because errors + can't be meaningfully reported afterwards. */ + if (!NILP (restart)) + { + /* This is very unlikely, but it's possible to execute a binary + (on some systems) with no argv. */ + if (initial_argc < 1) + error ("No command line arguments known; unable to re-execute Emacs"); + + /* Check that the binary hasn't gone away. */ + if (!file_access_p (initial_argv[0], F_OK)) + error ("Emacs executable \"%s\" can't be found", initial_argv[0]); + } +#endif + #ifdef HAVE_LIBSYSTEMD /* Notify systemd we are shutting down, but only if we have notified it about startup. */ @@ -2815,10 +2831,6 @@ killed. */ if (!NILP (restart)) { - /* This is very unlikely, but it's possible to execute a binary - (on some systems) with no argv. */ - if (initial_argc < 1) - emacs_perror ("No command line arguments known; unable to re-execute Emacs"); #ifdef WINDOWSNT if (w32_reexec_emacs (initial_cmdline, initial_wd) < 0) #else