Hi! Could I get some feedback on this patch? I've been running this for months now without any problems and it improves systemd support quite a bit...
Right now I'm relying on this for my desktop session which makes upgrades rather... brittle. :) a. On 2023-07-03 12:07:01, Antoine Beaupré wrote: > Control: tags -1 +patch > > And here's the patch to fix this. > > I'll also send this as a MR to salsa. > -- > Man is, at one and the same time, a solitary being and a social being, > - Albert Einstein > From 3c8450a9983da9904a81fc1313b5b4ae7fff0d43 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anar...@debian.org> > Date: Mon, 3 Jul 2023 11:32:53 -0400 > Subject: [PATCH 1/2] PATCH: signal readiness to sd-daemon > > This allows systemd to notice sway's startup is complete which allows, > for example, the session manager to start Wayland programs in the > right order. Without this signal, users have to go through rather > horrible hacks to tell systemd that it can start further units. > > I've been using `NotifyAccess=all` in the sway.service file and `exec > systemd-notify --ready` in my sway config to emulate this, but it's > racy and error-prone. > > A particularly nasty bug triggered by `NotifyAccess=all` in particular > is when podman starts and then terminates a container. In that > context, conmon(8) ends up notifying systemd it's the session master > and takes over thee "Main PID" field in systemd. When it dies, systemd > believes the session is over and proceeds to kill the entire > session. This is explained in more details in: > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1039857 > > This might not actually be the right place to do this. We call > `server_run` right after, and maybe there would be a better place. But > `server_run` only calls `wl_display_run` and that's part of the core > `wayland` library. I'm not sure Wayland itself is a place to do this, > so for now I'm scratching my own itch and doing this in Sway itself. > --- > debian/changelog | 7 ++ > .../0003-signal-readiness-to-sd-daemon.patch | 77 +++++++++++++++++++ > debian/patches/series | 1 + > 3 files changed, 85 insertions(+) > create mode 100644 debian/patches/0003-signal-readiness-to-sd-daemon.patch > > diff --git a/debian/changelog b/debian/changelog > index 12fc3b16..477c4bbf 100644 > --- a/debian/changelog > +++ b/debian/changelog > @@ -1,3 +1,10 @@ > +sway (1.8.1-1.1) experimental; urgency=medium > + > + * Non-maintainer upload. > + * Add patch for READY=1 signal to sd-daemon (Closes: #1039857) > + > + -- Antoine Beaupré <anar...@debian.org> Mon, 03 Jul 2023 11:16:48 -0400 > + > sway (1.8.1-1) experimental; urgency=medium > > * New upstream version > diff --git a/debian/patches/0003-signal-readiness-to-sd-daemon.patch > b/debian/patches/0003-signal-readiness-to-sd-daemon.patch > new file mode 100644 > index 00000000..13ac494c > --- /dev/null > +++ b/debian/patches/0003-signal-readiness-to-sd-daemon.patch > @@ -0,0 +1,77 @@ > +From d7cde9f35d93edd6c785e9404bed56094b702848 Mon Sep 17 00:00:00 2001 > +From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anar...@debian.org> > +Date: Mon, 3 Jul 2023 11:12:23 -0400 > +Subject: [PATCH] signal readiness to sd-daemon > + > +This allows systemd to notice sway's startup is complete which allows, > +for example, the session manager to start Wayland programs in the > +right order. Without this signal, users have to go through rather > +horrible hacks to tell systemd that it can start further units. > + > +I've been using `NotifyAccess=all` in the sway.service file and `exec > +systemd-notify --ready` in my sway config to emulate this, but it's > +racy and error-prone. > + > +A particularly nasty bug triggered by `NotifyAccess=all` in particular > +is when podman starts and then terminates a container. In that > +context, conmon(8) ends up notifying systemd it's the session master > +and takes over thee "Main PID" field in systemd. When it dies, systemd > +believes the session is over and proceeds to kill the entire > +session. This is explained in more details in: > + > +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1039857 > + > +This might not actually be the right place to do this. We call > +`server_run` right after, and maybe there would be a better place. But > +`server_run` only calls `wl_display_run` and that's part of the core > +`wayland` library. I'm not sure Wayland itself is a place to do this, > +so for now I'm scratching my own itch and doing this in Sway itself. > +--- > + sway/main.c | 11 +++++++++++ > + 1 file changed, 11 insertions(+) > + > +Index: b/sway/main.c > +=================================================================== > +--- a/sway/main.c 2023-07-03 11:52:40.761162143 -0400 > ++++ b/sway/main.c 2023-07-03 11:52:40.757162142 -0400 > +@@ -26,6 +26,12 @@ > + #include "stringop.h" > + #include "util.h" > + > ++#ifdef HAVE_LIBSYSTEMD > ++#include <systemd/sd-daemon.h> > ++#elif HAVE_LIBELOGIND > ++#include <elogind/sd-daemon.h> > ++#endif > ++ > + static bool terminate_request = false; > + static int exit_value = 0; > + static struct rlimit original_nofile_rlimit = {0}; > +@@ -412,6 +418,11 @@ int main(int argc, char **argv) { > + swaynag_show(&config->swaynag_config_errors); > + } > + > ++#if defined(HAVE_LIBSYSTEMD) || defined(HAVE_LIBELOGIND) > ++ /* Signal systemd that we are ready to accept connections */ > ++ sd_notify(0, "READY=1"); > ++#endif > ++ > + server_run(&server); > + > + shutdown: > +======= > +Index: b/sway/meson.build > +=================================================================== > +--- a/sway/meson.build 2023-07-03 11:52:40.761162143 -0400 > ++++ b/sway/meson.build 2023-07-03 11:56:14.121228707 -0400 > +@@ -235,6 +235,10 @@ if have_xwayland > + sway_deps += xcb > + endif > + > ++if sdbus.found() > ++ sway_deps += sdbus > ++endif > ++ > + executable( > + 'sway', > + sway_sources + wl_protos_src, > diff --git a/debian/patches/series b/debian/patches/series > index 271550d8..6147593d 100644 > --- a/debian/patches/series > +++ b/debian/patches/series > @@ -1,2 +1,3 @@ > 0001-Install-zsh-completions-into-the-correct-directory.patch > 0002-Modify-default-configuration-for-Debian.patch > +0003-signal-readiness-to-sd-daemon.patch > -- > 2.39.2 > -- Only after disaster can we be resurrected. It's only after you've lost everything that you're free to doanything. Nothing is static, everything is evolving, everything is falling apart. - Chuck Palahniuk, Fight Club