emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 3f61017: Avoid sending systemd shutdown notifications if non-da


From: Eli Zaretskii
Subject: emacs-27 3f61017: Avoid sending systemd shutdown notifications if non-daemon
Date: Fri, 22 Jan 2021 07:31:20 -0500 (EST)

branch: emacs-27
commit 3f610177adb844248fe37f52eb713d462e833a62
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid sending systemd shutdown notifications if non-daemon
    
    * src/emacs.c (Fkill_emacs): Send the shutdown notification only
    in daemon mode.  (Bug#46022)
---
 src/emacs.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index f2e858f..67220eb 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -187,7 +187,8 @@ bool build_details;
 /* Name for the server started by the daemon.*/
 static char *daemon_name;
 
-/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background).  */
+/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background).
+   A negative value means the daemon initialization was already done.  */
 int daemon_type;
 
 #ifndef WINDOWSNT
@@ -2371,7 +2372,10 @@ all of which are called before Emacs is actually killed. 
 */
   int exit_code;
 
 #ifdef HAVE_LIBSYSTEMD
-  sd_notify(0, "STOPPING=1");
+  /* Notify systemd we are shutting down, but only if we have notified
+     it about startup.  */
+  if (daemon_type == -1)
+    sd_notify(0, "STOPPING=1");
 #endif /* HAVE_LIBSYSTEMD */
 
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
@@ -2876,7 +2880,7 @@ from the parent process and its tty file descriptors.  */)
     }
 
   /* Set it to an invalid value so we know we've already run this function.  */
-  daemon_type = -1;
+  daemon_type = -daemon_type;
 
 #else  /* WINDOWSNT */
   /* Signal the waiting emacsclient process.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]