Skip to content

Commit

Permalink
Merge pull request #16433 from Luap99/systemd-check
Browse files Browse the repository at this point in the history
fix incorrect systemd booted check
  • Loading branch information
openshift-merge-robot authored Nov 7, 2022
2 parents 9e04bab + 919678d commit d60b25f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ var (
// RunsOnSystemd returns whether the system is using systemd
func RunsOnSystemd() bool {
runsOnSystemdOnce.Do(func() {
initCommand, err := os.ReadFile("/proc/1/comm")
// On errors, default to systemd
runsOnSystemd = err != nil || strings.TrimRight(string(initCommand), "\n") == "systemd"
// per sd_booted(3), check for this dir
fd, err := os.Stat("/run/systemd/system")
runsOnSystemd = err == nil && fd.IsDir()
})
return runsOnSystemd
}
Expand Down

0 comments on commit d60b25f

Please sign in to comment.