From 132099d0e303e4b17880b4982dbd066422a57dc1 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Mon, 30 Dec 2024 23:50:05 +0100 Subject: [PATCH] fixup --- restartable.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/restartable.go b/restartable.go index 19d208e..f989f94 100644 --- a/restartable.go +++ b/restartable.go @@ -138,20 +138,21 @@ func GetDeleted(fs ProcPidFS) ([]string, error) { // GetService retrieves the service name func GetService(fs ProcPidFS, userService bool) string { - cgroup, err := fs.ReadFile("cgroup") + data, err := fs.ReadFile("cgroup") if err != nil { return "-" } + cgroup := strings.TrimSpace(string(data)) var match []string if pid1 == "systemd" { if userService { - match = regexUserService.FindStringSubmatch(strings.TrimSpace(string(cgroup))) + match = regexUserService.FindStringSubmatch(cgroup) } else { - match = regexSystemService.FindStringSubmatch(strings.TrimSpace(string(cgroup))) + match = regexSystemService.FindStringSubmatch(cgroup) } } else if pid1 == "openrc" { - match = regexOpenRC.FindStringSubmatch(strings.TrimSpace(string(cgroup))) + match = regexOpenRC.FindStringSubmatch(cgroup) } if len(match) > 1 {