diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-04-18 11:02:55 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-04-18 11:02:55 +0200 |
commit | 9fc3b003730b90d88af11a31ea55c38fd733503b (patch) | |
tree | 59f4596c25d80a00a8a878c9963d9d57ff43842f /src/emacs.c | |
parent | e0009409b8cb0ce3810abf879e9e00c915724e47 (diff) | |
download | emacs-9fc3b003730b90d88af11a31ea55c38fd733503b.tar.gz emacs-9fc3b003730b90d88af11a31ea55c38fd733503b.tar.bz2 emacs-9fc3b003730b90d88af11a31ea55c38fd733503b.zip |
Improve `restart-emacs' error reporting
* src/emacs.c (Fkill_emacs): Do better error reporting on restarting.
Diffstat (limited to 'src/emacs.c')
-rw-r--r-- | src/emacs.c | 20 |
1 files changed, 16 insertions, 4 deletions
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 |