RFE: use systemd FD store for kwin_wayland_wrapper
Currently, KWin uses its own wrapper to hold wayland FD and track exit status. This means systemctl --user restart plasma-kwin_wayland.service
won't be handled properly.
systemd has a FD store mechanism where the service main process is able to upload arbitrary FDs to the service manager, so that they can survive restart. It should be able to replace the wrapper's process tracking part, as described below:
Initial run:
- wrapper sets up (X)wayland sockets and basic env
- wrapper uploads the FDs to fdstore, including a memfd that records socket names (or a
/etc/environment
-style env file) - wrapper execve() KWin, i.e. replaces itself
When KWin crashes, systemd is responsible for checking the exit status and restarting the wrapper. The new wrapper receives FDs passed by service manager and deserializes state from memfd. It then replaces itself with KWin, as with 3.
The crash counting can be implemented by quering for NRestarts
dbus property.
This enables KWin to survive systemctl restart
. Plus, by delegating process tracking to the service manager, the unit status correctly reflects the status of KWin.
To make sure that the stop of plasma-kwin_wayland.service
won't bring down dependents, RestartMode=direct
can be used if desired.