unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tim Ruffing <public@timruffing.de>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 45181@debbugs.gnu.org
Subject: bug#45181: 27.1; exit status and emacs.service
Date: Mon, 14 Dec 2020 16:08:34 +0100	[thread overview]
Message-ID: <de2369e63c93be924126a6f2498ba4bb2d08b27e.camel@timruffing.de> (raw)
In-Reply-To: <87im9884ma.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

I attached a patch. Feel free to edit (including the commit message --
I tried to mimic the format, I hope it's fine). This patch works fine
for me locally.

Best,
Tim

On Fri, 2020-12-11 at 21:33 +0100, Lars Ingebrigtsen wrote:
> Tim Ruffing <public@timruffing.de> writes:
> 
> > I think the proper thing to do is 
> >  - remove the ExecStop line (it's at least redundant and confusing)
> >  - add SuccessExitStatus=15 (to tell systemd that 15 is fine)
> 
> Thanks for the analysis of the situation.  This sounds like the right
> solution -- could you submit a patch for the emacs.service file? 
> Even
> if this sounds like an easy fix, I don't use systemd myself for
> Emacs,
> so I can't verify that the end result is correct (if I were to do the
> changes myself).
> 


[-- Attachment #2: 0001-etc-emacs.service.patch --]
[-- Type: text/x-patch, Size: 1704 bytes --]

From d5c31deca10b2166616059d0345f77605ca5ed6e Mon Sep 17 00:00:00 2001
From: Tim Ruffing <crypto@timruffing.de>
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


  reply	other threads:[~2020-12-14 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 16:28 bug#45181: 27.1; exit status and emacs.service Tim Ruffing
2020-12-11 20:33 ` Lars Ingebrigtsen
2020-12-14 15:08   ` Tim Ruffing [this message]
2020-12-14 17:00     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de2369e63c93be924126a6f2498ba4bb2d08b27e.camel@timruffing.de \
    --to=public@timruffing.de \
    --cc=45181@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).