liske / needrestart

Restart daemons after library updates.
GNU General Public License v2.0
426 stars 67 forks source link

RFC: better `systemd --user` integration #301

Open intelfx opened 6 months ago

intelfx commented 6 months ago

Right now, processes running under systemd --user confuse needrestart in several ways:

  1. for processes that did not double-fork, needrestart considers systemd --user as the logical parent (which means that needrestart will bogusly report systemd itself as the process that needs to be restarted);
  2. when the systemd --user instance itself needs a restart, needrestart won't do anything about it;
  3. if the process to be restarted is a user service under systemd --user (as opposed to an arbitrary process started in a user scope), needrestart won't use this information in any way.

This PR offers a clean solution for (1) by disregarding the parent if it is a systemd --user instance (implemented via matching the cgroup of the parent against /init.scope$), and pretty hacky solutions for (2) and (3) (hence the RFC status).

Vladimir-csp commented 5 months ago

Can this be useful for #289?

intelfx commented 5 months ago

@Vladimir-csp yes, I believe it can. This needs a bit more UI work (the code I wrote piggybacks on existing data structures used for raw session processes, so it does not offer to perform a systemctl --user restart), but in principle this code already performs detection of user services which is what you ask for.