GNU bug report logs - #31498
[PATCH] Notify systemd in daemon-initialized

Previous Next

Package: emacs;

Reported by: Lucas Werkmeister <mail <at> lucaswerkmeister.de>

Date: Fri, 18 May 2018 17:46:02 UTC

Severity: wishlist

Tags: fixed, patch

Merged with 31521

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Subject: [PATCH] Notify systemd in daemon-initialized
Date: Fri, 18 May 2018 19:40:31 +0200
With --[bg-]daemon and Type=forking, systemd will only consider the
daemon to have fully started up once the original process exits, and
will wait until then to start units depending on the Emacs service. To
get the same functionality with --fg-daemon, use Type=notify instead of
Type=simple and explicitly send a readiness notification to systemd at
the point where the forked process would in --bg-daemon mode notify its
parent process and cause it to exit.
* etc/emacs.service: update Type
* src/emacs.c (daemon-initialized): call sd_notify()
---
 etc/emacs.service | 2 +-
 src/emacs.c       | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/etc/emacs.service b/etc/emacs.service
index b29177b120..dbcb6bc301 100644
--- a/etc/emacs.service
+++ b/etc/emacs.service
@@ -7,7 +7,7 @@ Description=Emacs text editor
 Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
 
 [Service]
-Type=simple
+Type=notify
 ExecStart=emacs --fg-daemon
 ExecStop=emacsclient --eval "(kill-emacs)"
 Environment=SSH_AUTH_SOCK=%t/keyring/ssh
diff --git a/src/emacs.c b/src/emacs.c
index f25e612664..8718b301a4 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2477,6 +2477,13 @@ from the parent process and its tty file descriptors.  */)
     error ("This function can only be called after loading the init files");
 #ifndef WINDOWSNT
 
+  if (daemon_type == 1)
+    {
+#ifdef HAVE_LIBSYSTEMD
+      sd_notify(0, "READY=1");
+#endif /* HAVE_LIBSYSTEMD */
+    }
+
   if (daemon_type == 2)
     {
       int nfd;
-- 
2.17.0





This bug report was last modified 7 years and 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.