emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#46022: closed (27.1; kill-emacs should call sd_notify only in daemon


From: GNU bug Tracking System
Subject: bug#46022: closed (27.1; kill-emacs should call sd_notify only in daemon mode)
Date: Fri, 22 Jan 2021 12:32:02 +0000

Your message dated Fri, 22 Jan 2021 14:31:43 +0200
with message-id <83eeid5f0w.fsf@gnu.org>
and subject line Re: bug#46022: 27.1; kill-emacs should call sd_notify only in 
daemon mode
has caused the debbugs.gnu.org bug report #46022,
regarding 27.1; kill-emacs should call sd_notify only in daemon mode
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
46022: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=46022
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 27.1; kill-emacs should call sd_notify only in daemon mode Date: Thu, 21 Jan 2021 17:26:31 +0100
When run with --fg-daemon mode (as done by the provided systemd unit
file "emacs.service"), emacs will call sd_notify() on startup to notify
systemd about its status. On exit, emacs will call sd_notify()
unconditionally, i.e., even when not run in daemon mode.

This means that when the daemon is running, other emacs processes
derived from the main process (e.g., in batch mode started by the async
package) may send exit notifications when they're exiting, even though
the main daemon process is not exiting. systemd will (correctly) ignore
these notifications because they come from the wrong PID; this is the
lucky default value of "NotifyAccess=main" in the systemd unit, i.e.,
only the main PID may send notifications. However, systemd will also
emit a warning in this case. With my config, this results in a lot of
warning messages in the systemd user journal:
Jan 20 14:23:06 systemd[1309]: emacs.service: Got notification message from PID 
271936, but reception only permitted for main PID 1365
Jan 20 14:24:06 systemd[1309]: emacs.service: Got notification message from PID 
271956, but reception only permitted for main PID 1365
Jan 20 14:25:07 systemd[1309]: emacs.service: Got notification message from PID 
271983, but reception only permitted for main PID 1365
Jan 20 14:26:06 systemd[1309]: emacs.service: Got notification message from PID 
272071, but reception only permitted for main PID 1365
Jan 20 14:27:06 systemd[1309]: emacs.service: Got notification message from PID 
272092, but reception only permitted for main PID 1365
Jan 20 14:28:06 systemd[1309]: emacs.service: Got notification message from PID 
272127, but reception only permitted for main PID 1365
Jan 20 14:29:06 systemd[1309]: emacs.service: Got notification message from PID 
272304, but reception only permitted for main PID 1365
Jan 20 14:30:06 systemd[1309]: emacs.service: Got notification message from PID 
272442, but reception only permitted for main PID 1365 

I admit that this config may be exotic but the core of the issue is not
the number of messages, it's simply that there shouldn't be any
notification (nor warning).

So I think the right thing to do is to call sd_notify in kill-emacs
only when we run in foreground daemon mode, i.e., if daemon_type == 1.
This is done when calling sd_notify in daemon-initialized. I assume the
check was omitted in kill-emacs because daemon-initialized sets
daemon_type = -1, so this information is no longer accessible when
kill-emacs runs (and it was believed sd-notify is a no-op anyway in
those cases -- but that's only partly true due to warning message).
 
In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22,
cairo version 1.17.3)
 of 2020-08-28 built on juergen
Windowing system distributor 'The X.Org Foundation', version
11.0.12010000
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int
 --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2 GMP





--- End Message ---
--- Begin Message --- Subject: Re: bug#46022: 27.1; kill-emacs should call sd_notify only in daemon mode Date: Fri, 22 Jan 2021 14:31:43 +0200
> From: Tim Ruffing <public@timruffing.de>
> Cc: 46022@debbugs.gnu.org
> Date: Fri, 22 Jan 2021 13:07:35 +0100
> 
> I tested the patch and I can conform that it works and makes the
> warnings disappear. 

Thanks, I've now installed the change on the emacs-27 branch, and I'm
closing this bug report.


--- End Message ---

reply via email to

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