Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --ready-fd #281

Merged
merged 1 commit into from Jan 28, 2023
Merged

Add --ready-fd #281

merged 1 commit into from Jan 28, 2023

Conversation

emersion
Copy link
Member

@emersion emersion commented Jan 27, 2023

This implements a readiness notification mechanism which works on
both systemd and s6.

References: #42
References: #275

Depends on #280

@emersion emersion marked this pull request as ready for review January 28, 2023 21:52
This implements a readiness notification mechanism which works on
both systemd and s6.

References: #42
References: #275
Copy link
Member

@kennylevinsen kennylevinsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and does what it says on the tin. swaylock also desperately needed more command-line arguments. :P

@kennylevinsen kennylevinsen merged commit db9ee6d into master Jan 28, 2023
@kennylevinsen kennylevinsen deleted the ready-fd branch January 28, 2023 22:04
anarcat added a commit to anarcat/sway that referenced this pull request Jan 9, 2024
This adds a new commandline option, --ready-fd, to send a notification
when sway is ready to run.

This allows a process supervisor 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 horrible hacks to order services.

For example, I've been using `NotifyAccess=all` in the `sway.service`
file and `exec systemd-notify --ready` in my sway config to emulate
this. Problem is it's racy and error-prone.

A particularly nasty bug triggered by `NotifyAccess=all` 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 `MainPID` 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 in the sway
startup sequence, that said. We call `server_run` right after, and
maybe somewhere below that would be a better place. But `server_run`
only calls `wl_display_run` and that's part of the core wayland
library, so that seems a little too far down. 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.

Note that this approach was taken instead of using the proper
`sd_notify` library call, as that approach was refused in swaywm#7659. The
`--ready-fd` approach was accepted in swaywm/swaylock#281 so it is
hoped it will be seen as acceptable here.

An alternative implementation would be to instead check the
`NOTIFY_SOCKET` environment variable and use that, if present. That
variable is used by systemd and at least the s6 supervisor to receive
readiness notifications, so it might be less disruptive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants