needrestart
                                
                                 needrestart copied to clipboard
                                
                                    needrestart copied to clipboard
                            
                            
                            
                        RFC: better `systemd --user` integration
Right now, processes running under systemd --user confuse needrestart in several ways:
- for processes that did not double-fork, needrestart considers systemd --useras the logical parent (which means that needrestart will bogusly reportsystemditself as the process that needs to be restarted);
- when the systemd --userinstance itself needs a restart, needrestart won't do anything about it;
- 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).
Can this be useful for #289?
@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.
@liske ping, is there any chance this PR could get reviewed? There has been a new release since this PR was posted, so I'm assuming there must be some sort of problem with this code specifically?
@liske ping, is there any chance this PR could get reviewed? There has been a new release since this PR was posted, so I'm assuming there must be some sort of problem with this code specifically?
Sorry the security fixes for 3.8 have taken some time over the last few weeks and I was not able to take time for this more complex issue, yet. Scheduling it for the next release.
Thanks. I just wanted to make sure this PR would actually be desired before I rebase it on top of the new changes.
Systemd-managed user sessions with apps in units were already a reality in Gnome and at least some other major DEs.
I helped a bit to make it happen in independent compositors also.
I need to reschedule this for 3.10. Needrestart 3.9 will be release ASAP to fix the regression reported in #317.
I did a first review and it looks almost good to me. Are you going to remove the trace() functions in the restart.d scripts? I'm fine with the solution you implemented in ac804df3953429a3aee6d3f2bffd30c24f166851.
Are you going to remove the trace() functions in the restart.d scripts?
Oh. I left it in by accident. Although, now that I look at it again, I should probably change it to kill the user manager with SIGRTMIN+25 — this is more portable than systemctl -M [email protected] syntax.
Are you going to remove the trace() functions in the restart.d scripts?
Oh. I left it in by accident. Although, now that I look at it again, I should probably change it to kill the user manager with
SIGRTMIN+25— this is more portable thansystemctl -M [email protected]syntax.
Thanks! So this PR (and #302) can now be merged? Just asking due to the RFC:  in the PR title ;)
Thanks!