unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Set known success exit status in emacs.service
@ 2020-01-02 11:40 Florian Schmaus
  2020-01-02 11:53 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Schmaus @ 2020-01-02 11:40 UTC (permalink / raw)
  To: emacs-devel

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

It appears that the emacs daemon will terminate with an exit code value
'15' once kill-emacs is invoked. If the daemon is run with the example
emacs.service systemd file from the source repository, then systemd
reports and records an unsuccessful exit:

systemd[4908]: Stopping Emacs text editor...
sh[415489]: Saving file /home/user/.emacs.d/recentf...
sh[415489]: Wrote /home/user/.emacs.d/recentf
systemd[4908]: emacs-26.service: Main process exited, code=exited,
  status=15/n/a
systemd[4908]: emacs-26.service: Failed with result 'exit-code'.
systemd[4908]: Stopped Emacs text editor.
systemd[4908]: emacs-26.service: Consumed 1.536s CPU time.

The applied patch adds

SuccessExitStatus=15

to the emacs.service file, which makes systemd recognize the exit as a
successful one.

As I was unable to find documentation about the exit codes of emacs, I
wonder if there are other exit codes besides 0 and 15 that should/could
be considered a successful exit, and hence, should be listed in the
example systemd service file SuccessExitStatus configuration?

- Florian

[-- Attachment #2: 0001-Set-known-success-exit-status-in-emacs.service.patch --]
[-- Type: text/x-patch, Size: 1149 bytes --]

From 1f767a005dc55ac669f0dc400ca1e98ecd43ede5 Mon Sep 17 00:00:00 2001
From: Florian Schmaus <flo@geekplace.eu>
Date: Thu, 2 Jan 2020 12:26:07 +0100
Subject: [PATCH] Set known success exit status in emacs.service

As otherwise systemd will report and record an unsuccessful exit when
terminating the service:

systemd[4908]: Stopping Emacs text editor...
sh[415489]: Saving file /home/user/.emacs.d/recentf...
sh[415489]: Wrote /home/user/.emacs.d/recentf
systemd[4908]: emacs-26.service: Main process exited, code=exited, status=15/n/a
systemd[4908]: emacs-26.service: Failed with result 'exit-code'.
systemd[4908]: Stopped Emacs text editor.
systemd[4908]: emacs-26.service: Consumed 1.536s CPU time.
---
 etc/emacs.service | 1 +
 1 file changed, 1 insertion(+)

diff --git a/etc/emacs.service b/etc/emacs.service
index c99c6779f58..3d03801ba2b 100644
--- a/etc/emacs.service
+++ b/etc/emacs.service
@@ -14,6 +14,7 @@ ExecStop=emacsclient --eval "(kill-emacs)"
 # set it from PAM, so don't override by default.
 # Environment=SSH_AUTH_SOCK=%t/keyring/ssh
 Restart=on-failure
+SuccessExitStatus=15
 
 [Install]
 WantedBy=default.target
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Set known success exit status in emacs.service
  2020-01-02 11:40 Set known success exit status in emacs.service Florian Schmaus
@ 2020-01-02 11:53 ` Andreas Schwab
  2020-01-02 19:45   ` Florian Schmaus
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2020-01-02 11:53 UTC (permalink / raw)
  To: Florian Schmaus; +Cc: emacs-devel

On Jan 02 2020, Florian Schmaus wrote:

> It appears that the emacs daemon will terminate with an exit code value
> '15' once kill-emacs is invoked.

Please find out why the exit code isn't zero.

> As I was unable to find documentation about the exit codes of emacs,

The exit code is whatever is passed to kill-emacs.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Set known success exit status in emacs.service
  2020-01-02 11:53 ` Andreas Schwab
@ 2020-01-02 19:45   ` Florian Schmaus
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Schmaus @ 2020-01-02 19:45 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel



On 1/2/20 12:53 PM, Andreas Schwab wrote:
> On Jan 02 2020, Florian Schmaus wrote:
> 
>> It appears that the emacs daemon will terminate with an exit code value
>> '15' once kill-emacs is invoked.
> 
> Please find out why the exit code isn't zero.

I tried, but without success so far. I was unable to reproduce this
without systemd, so I assume it is caused or at least related to
systemd. Furthermore, the exit code value '15' smells like SIGTERM being
involved.

> 
>> As I was unable to find documentation about the exit codes of emacs,
> 
> The exit code is whatever is passed to kill-emacs.

Well, kill-emacs is invoked without any arguments:

ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"

so I assume the exit code stems from something else.

Any pointers which shed some light into what is causing emacs to return
this exit code would be appreciated. Right now, I am stuck.

- Florian



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-02 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 11:40 Set known success exit status in emacs.service Florian Schmaus
2020-01-02 11:53 ` Andreas Schwab
2020-01-02 19:45   ` Florian Schmaus

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).