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

RFC: better systemd --user integration #301

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

intelfx
Copy link

@intelfx intelfx commented Apr 19, 2024

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).

Ignore $ppid if it is an instance of the systemd manager.
This prevents `systemd --user` from being treated as a parent process
of all non-double-forked `systemd --user` services.
Ideally, we'd do something more reasonable, like treating them similarly
to system services and maybe even offering to restart some of them or
at the very least printing them in a format suitable for copy-pasting,
but for now just replace the process name with the service name and
save them under a separate key to hopefully distinguish them from
other processes under `systemd --user`.
@Vladimir-csp
Copy link
Contributor

Can this be useful for #289?

@intelfx
Copy link
Author

intelfx commented May 29, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants