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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31498 in the body.
You can then email your comments to 31498 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Fri, 18 May 2018 17:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lucas Werkmeister <mail <at> lucaswerkmeister.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 18 May 2018 17:46:02 GMT) Full text and rfc822 format available.

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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Thu, 07 Jun 2018 13:10:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized
Date: Thu, 07 Jun 2018 09:08:51 -0400
severity 31498 wishlist
severity 31521 wishlist
quit


Thanks, the patch seems straightforward enough.  Just a few minor
comments about formatting.  Have you assigned copyright for Emacs?  The
patch is small enough to go in anyway, it would just have to be marked.

Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:

> 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
                                                                     ^
                                                                     double space
> 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

The ChangeLog entries should be captilalized and end with a period:
"Update Type."

> * src/emacs.c (daemon-initialized): call sd_notify()

Same here.

I think it should have a NEWS entry mentioning that Emacs now supports
this systemd notification feature.  I would probably go ahead and
combine with #31521, since it's using the same feature.





Severity set to 'wishlist' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 07 Jun 2018 13:10:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Thu, 07 Jun 2018 15:39:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31498 <at> debbugs.gnu.org, mail <at> lucaswerkmeister.de
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized
Date: Thu, 07 Jun 2018 18:38:12 +0300
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Thu, 07 Jun 2018 09:08:51 -0400
> Cc: 31498 <at> debbugs.gnu.org
> 
> Have you assigned copyright for Emacs?

I don't see an assignment for Lucas Werkmeister on file.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Thu, 07 Jun 2018 21:40:01 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized
Date: Thu, 7 Jun 2018 23:40:08 +0200
Thanks for the review! Replies inline.

On 07.06.2018 15:08, Noam Postavsky wrote:
> severity 31498 wishlist
> severity 31521 wishlist
> quit
> 
> 
> Thanks, the patch seems straightforward enough.  Just a few minor
> comments about formatting.  Have you assigned copyright for Emacs?  The
> patch is small enough to go in anyway, it would just have to be marked.

I haven’t assigned copyright yet, but I’d be happy to do so – I’ve tried
to get the process started on emacs-devel.

> 
> Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:
> 
>> 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
>                                                                      ^
>                                                                      double space

ack

>> 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
> 
> The ChangeLog entries should be captilalized and end with a period:
> "Update Type."
> 
>> * src/emacs.c (daemon-initialized): call sd_notify()
> 
> Same here.

2× ack

> 
> I think it should have a NEWS entry mentioning that Emacs now supports
> this systemd notification feature.  I would probably go ahead and
> combine with #31521, since it's using the same feature.
> 

Do you mean, announce both in this patch, or completely merge that patch
into this one?

Once I’ve fixed the problems locally, what’s the best way to re-roll the
patch in this bug tracking system? Should I try to configure `git
send-email` to reply to the right email (and with the right bug in CC),
or perhaps use `git format-patch` and add the patch file as a regular
attachment in a manual response?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Fri, 08 Jun 2018 00:42:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized
Date: Thu, 07 Jun 2018 20:41:36 -0400
Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:

> I haven’t assigned copyright yet, but I’d be happy to do so – I’ve tried
> to get the process started on emacs-devel.

Cool, since this patch will be destined for Emacs 27, there's not much
urgency, so I'll wait for that to resolve before pushing.

>> I think it should have a NEWS entry mentioning that Emacs now supports
>> this systemd notification feature.  I would probably go ahead and
>> combine with #31521, since it's using the same feature.
>> 
>
> Do you mean, announce both in this patch, or completely merge that patch
> into this one?

The latter (maybe it would have been clearer to put those two sentences
in separate paragraphs).

> Once I’ve fixed the problems locally, what’s the best way to re-roll the
> patch in this bug tracking system? Should I try to configure `git
> send-email` to reply to the right email (and with the right bug in CC),
> or perhaps use `git format-patch` and add the patch file as a regular
> attachment in a manual response?

Either way is fine I guess, though I've never tried 'git send-email'
myself.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 10:29:02 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Cc: Noam Postavsky <npostavs <at> gmail.com>,
 Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Subject: [PATCH] Notify systemd in daemon-initialized and kill-emacs
Date: Sat,  9 Jun 2018 12:27:26 +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. Similarly, notify systemd at the
beginning of the shutdown process as well. (Both of these calls are
successful no-ops if emacs was not started by systemd.)
* etc/emacs.service: Update Type.
* src/emacs.c (daemon-initialized): Call sd_notify().
* src/emacs.c (kill-emacs): Call sd_notify().
---
 etc/emacs.service |  2 +-
 src/emacs.c       | 11 +++++++++++
 2 files changed, 12 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 8633e934e5..cde20fc096 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2017,6 +2017,10 @@ all of which are called before Emacs is actually killed.  */
 {
   int exit_code;
 
+#ifdef HAVE_LIBSYSTEMD
+  sd_notify(0, "STOPPING=1");
+#endif /* HAVE_LIBSYSTEMD */
+
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
      set.  */
   waiting_for_input = 0;
@@ -2477,6 +2481,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.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 10:56:01 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Date: Sat, 9 Jun 2018 12:55:48 +0200
[Message part 1 (text/plain, inline)]
sorry, forgot the double-space after periods after editing the commit
message, rerolling

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 10:57:02 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Cc: Noam Postavsky <npostavs <at> gmail.com>,
 Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Subject: [PATCH] Notify systemd in daemon-initialized and kill-emacs
Date: Sat,  9 Jun 2018 12:56:16 +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.  Similarly, notify systemd at the
beginning of the shutdown process as well.  (Both of these calls are
successful no-ops if emacs was not started by systemd.)
* etc/emacs.service: Update Type.
* src/emacs.c (daemon-initialized): Call sd_notify().
* src/emacs.c (kill-emacs): Call sd_notify().
---
 etc/emacs.service |  2 +-
 src/emacs.c       | 11 +++++++++++
 2 files changed, 12 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 8633e934e5..cde20fc096 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2017,6 +2017,10 @@ all of which are called before Emacs is actually killed.  */
 {
   int exit_code;
 
+#ifdef HAVE_LIBSYSTEMD
+  sd_notify(0, "STOPPING=1");
+#endif /* HAVE_LIBSYSTEMD */
+
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
      set.  */
   waiting_for_input = 0;
@@ -2477,6 +2481,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.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 12:30:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Sat, 09 Jun 2018 08:29:22 -0400
> >> I think it should have a NEWS entry mentioning that Emacs now supports
> >> this systemd notification feature.  I would probably go ahead and
> >> combine with #31521, since it's using the same feature.
> >> 
> >
> > Do you mean, announce both in this patch, or completely merge that patch
> > into this one?

> The latter (maybe it would have been clearer to put those two sentences
> in separate paragraphs).

I think I still managed to be unclear about this; I meant you should
both announce the change in etc/NEWS, and merge the patches.

Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:

> 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.  Similarly, notify systemd at the
> beginning of the shutdown process as well.  (Both of these calls are
> successful no-ops if emacs was not started by systemd.)
> * etc/emacs.service: Update Type.
> * src/emacs.c (daemon-initialized): Call sd_notify().
> * src/emacs.c (kill-emacs): Call sd_notify().

Thanks, I think I still managed to be unclear about the 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 12:32:01 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Sat, 9 Jun 2018 14:31:23 +0200
On 09.06.2018 14:29, Noam Postavsky wrote:
> 
> I think I still managed to be unclear about this; I meant you should
> both announce the change in etc/NEWS, and merge the patches.

Sorry, no, that’s not your fault, I just forgot :) will reroll




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 12:37:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Sat, 09 Jun 2018 08:36:02 -0400
Noam Postavsky <npostavs <at> gmail.com> writes:

> Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:
>
>> * etc/emacs.service: Update Type.
>> * src/emacs.c (daemon-initialized): Call sd_notify().
>> * src/emacs.c (kill-emacs): Call sd_notify().

Oops, hit send too early.  I wanted to add, that you don't need to
repeat the same message for the last two ChangeLog entries, and you
should use the "Conditional Changes" syntax [1], like so:

* src/emacs.c (daemon-initialized) [HAVE_LIBSYSTEMD]:
* src/emacs.c (kill-emacs) [HAVE_LIBSYSTEMD]: Call sd_notify().

[1]: https://www.gnu.org/prep/standards/html_node/Conditional-Changes.html

PS I was wrong about 'git send-email' being just as good as replying
with attachment.  The bug tracker adds a "bug#xxxxx:" prefix, so I end
up getting duplicate emails.  Next time someone asks I'll know what to
answer :)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 13:01:02 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Sat, 9 Jun 2018 15:00:15 +0200
> PS I was wrong about 'git send-email' being just as good as replying
> with attachment.  The bug tracker adds a "bug#xxxxx:" prefix, so I end
> up getting duplicate emails.  Next time someone asks I'll know what to
> answer :)
> 

Sorry, I think that was just because I manually added you to CC. I’ll
skip that for the next time and we’ll see if it’s better, okay? :)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 13:02:01 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Cc: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Subject: [PATCH] Notify systemd in daemon-initialized and kill-emacs
Date: Sat,  9 Jun 2018 15:01:08 +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.  Similarly, notify systemd at the
beginning of the shutdown process as well.  (Both of these calls are
successful no-ops if emacs was not started by systemd.)
* etc/emacs.service: Update Type.
* src/emacs.c (daemon-initialized) [HAVE_LIBSYSTEMD]:
* src/emacs.c (kill-emacs) [HAVE_LIBSYSTEMD]: Call sd_notify().
---
 etc/NEWS          |  8 ++++++++
 etc/emacs.service |  2 +-
 src/emacs.c       | 11 +++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 4ea3440754..ba693e7e52 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -74,6 +74,14 @@ work right without some adjustment:
 - you can use the new 'package-quickstart' so activation of packages does not
   need to pay attention to 'package-load-list' or 'package-user-dir' any more.
 
+---
+** Emacs now notifies systemd when startup finishes or shutdown begins.
+Units that are ordered after 'emacs.service' will only be started
+after Emacs has finished initialization and is ready for use.
+(If your Emacs is installed in a non-standard location and you copied the
+emacs.service file to eg ~/.config/systemd/user/, you will need to copy
+the new version of the file again.)
+
 
 * Changes in Emacs 27.1
 
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 8633e934e5..cde20fc096 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2017,6 +2017,10 @@ all of which are called before Emacs is actually killed.  */
 {
   int exit_code;
 
+#ifdef HAVE_LIBSYSTEMD
+  sd_notify(0, "STOPPING=1");
+#endif /* HAVE_LIBSYSTEMD */
+
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
      set.  */
   waiting_for_input = 0;
@@ -2477,6 +2481,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.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Sat, 09 Jun 2018 14:06:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Sat, 09 Jun 2018 10:05:47 -0400
Lucas Werkmeister <mail <at> lucaswerkmeister.de> writes:

>> PS I was wrong about 'git send-email' being just as good as replying
>> with attachment.  The bug tracker adds a "bug#xxxxx:" prefix, so I end
>> up getting duplicate emails.  Next time someone asks I'll know what to
>> answer :)
>> 
>
> Sorry, I think that was just because I manually added you to CC. I’ll
> skip that for the next time and we’ll see if it’s better, okay? :)

It's okay for this thread because I'm subscribed to the bug list, but in
general, if there were non-subscribed people discussing the bug then
they wouldn't have received the patch.


Anyway, the latest patch looks good, please ping the thread again when
the copyright stuff is done and I'll push to master.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Wed, 13 Jun 2018 13:43:01 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Wed, 13 Jun 2018 15:42:41 +0200
On 09.06.2018 16:05, Noam Postavsky wrote:> Anyway, the latest patch
looks good, please ping the thread again when
> the copyright stuff is done and I'll push to master.
> 

I think it’s done now, I just received a signed copy of the assignment
document (dated June 8th).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Wed, 13 Jun 2018 16:35:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and
 kill-emacs
Date: Wed, 13 Jun 2018 19:33:57 +0300
> From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
> Date: Wed, 13 Jun 2018 15:42:41 +0200
> 
> On 09.06.2018 16:05, Noam Postavsky wrote:> Anyway, the latest patch
> looks good, please ping the thread again when
> > the copyright stuff is done and I'll push to master.
> > 
> 
> I think it’s done now, I just received a signed copy of the assignment
> document (dated June 8th).

Your assignment is not yet on file, so let's please wait a few more
days for it to appear, which is a sign for us that the paperwork is
complete.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Thu, 12 Jul 2018 22:21:02 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and,
 kill-emacs
Date: Fri, 13 Jul 2018 00:20:15 +0200
Any news on the copyright status? I haven’t received any further emails
from the FSF on this, so if there’s anything I still need to do, please
let me know :)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Fri, 13 Jul 2018 06:59:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and,
 kill-emacs
Date: Fri, 13 Jul 2018 09:58:47 +0300
> From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
> Date: Fri, 13 Jul 2018 00:20:15 +0200
> 
> Any news on the copyright status? I haven’t received any further emails
> from the FSF on this, so if there’s anything I still need to do, please
> let me know :)

Please ping the copyright clerk.  Your name is still not on file.

Sorry for the delay.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Wed, 25 Jul 2018 12:04:02 GMT) Full text and rfc822 format available.

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

From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
To: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and,,
 kill-emacs
Date: Wed, 25 Jul 2018 14:03:08 +0200
I’ve been notified that my name should be on the file now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Wed, 25 Jul 2018 14:49:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Cc: 31498 <at> debbugs.gnu.org
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and, ,
 kill-emacs
Date: Wed, 25 Jul 2018 17:48:28 +0300
> From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
> Date: Wed, 25 Jul 2018 14:03:08 +0200
> 
> I’ve been notified that my name should be on the file now.

Indeed, it is.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31498; Package emacs. (Thu, 26 Jul 2018 01:14:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 31498 <at> debbugs.gnu.org, Lucas Werkmeister <mail <at> lucaswerkmeister.de>
Subject: Re: bug#31498: [PATCH] Notify systemd in daemon-initialized and, ,
 kill-emacs
Date: Wed, 25 Jul 2018 21:13:50 -0400
merge 31498 31521
tags 31498 fixed
close 31498 27.1
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Lucas Werkmeister <mail <at> lucaswerkmeister.de>
>> Date: Wed, 25 Jul 2018 14:03:08 +0200
>> 
>> I’ve been notified that my name should be on the file now.
>
> Indeed, it is.

I've pushed to master.

[1: 19f5f7b19b]: 2018-07-25 21:07:03 -0400
  Notify systemd in daemon-initialized and kill-emacs (Bug#31498)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=19f5f7b19b0dcdae87476a3fd51c41f840b2b80f




Merged 31498 31521. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 26 Jul 2018 01:14:04 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 26 Jul 2018 01:14:04 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 31498 <at> debbugs.gnu.org and Lucas Werkmeister <mail <at> lucaswerkmeister.de> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 26 Jul 2018 01:14:05 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Aug 2018 11:24:05 GMT) Full text and rfc822 format available.

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.