Skip to content

Commit

Permalink
needrestart: hack: recognize services under systemd --user as units
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
intelfx committed Apr 19, 2024
1 parent 8cc2589 commit 038b071
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions needrestart
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,14 @@ if(defined($opt_l)) {
push(@{ $sessions{$1}->{"session #$2"}->{ $ptable->{$pid}->{fname} } }, $pid);
next;
}
if($cgroup =~ m@/user\@(\d+)\.service(/.+)?/([^/]+\.service)$@) {
print STDERR "$LOGPREF #$pid part of user service: uid=$1 unit=$3\n" if($nrconf{verbosity} > 1);
push(@{ $sessions{$1}->{'user service'}->{ $3 } }, $pid);
next;
}
if($cgroup =~ m@/user\@(\d+)\.service@) {
print STDERR "$LOGPREF #$pid part of user manager service: uid=$1\n" if($nrconf{verbosity} > 1);
push(@{ $sessions{$1}->{'user manager service'}->{ $ptable->{$pid}->{fname} } }, $pid);
print STDERR "$LOGPREF #$pid part of user manageruid=$1\n" if($nrconf{verbosity} > 1);
push(@{ $sessions{$1}->{'user manager'}->{ $ptable->{$pid}->{fname} } }, $pid);
next;
}
if($cgroup =~ m@/machine.slice/machine.qemu(.*).scope@) {
Expand Down

0 comments on commit 038b071

Please sign in to comment.