From d5c31deca10b2166616059d0345f77605ca5ed6e Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Mon, 14 Dec 2020 15:43:41 +0100 Subject: [PATCH] * etc/emacs.service: Before this commit, emacs.service contained an ExecStop command which invokes (kill-emacs) via emacsclient. This was redundant because systemd will be default send SIGTERM, which Emacs will handle by calling (kill-emacs). Moreover, the command violated the contract of ExecStop because emacsclient does not wait until the emacs server has properly stopped. This led to systemd issuing SIGTERM anyway after emacsclient exits, making Emacs exit with non-zero status 15 due to the SIGTERM, and letting systemd believe that stopping was done properly. This commit removes the ExecStop command such that only SIGTERM will be used to stop the service. This commit also adds 15 to the list of acceptable exit codes because it is not supposed to indicate failure in this case. --- etc/emacs.service | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/emacs.service b/etc/emacs.service index c99c6779f5..809c49cdbc 100644 --- a/etc/emacs.service +++ b/etc/emacs.service @@ -9,7 +9,11 @@ Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/ [Service] Type=notify ExecStart=emacs --fg-daemon -ExecStop=emacsclient --eval "(kill-emacs)" + +# Emacs will exit with status 15 after having received SIGTERM, which +# is the default "KillSignal" value systemd uses to stop services. +SuccessExitStatus=15 + # The location of the SSH auth socket varies by distribution, and some # set it from PAM, so don't override by default. # Environment=SSH_AUTH_SOCK=%t/keyring/ssh -- 2.29.2