mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
Merge pull request #16433 from Luap99/systemd-check
fix incorrect systemd booted check
This commit is contained in:
@ -113,9 +113,9 @@ var (
|
|||||||
// RunsOnSystemd returns whether the system is using systemd
|
// RunsOnSystemd returns whether the system is using systemd
|
||||||
func RunsOnSystemd() bool {
|
func RunsOnSystemd() bool {
|
||||||
runsOnSystemdOnce.Do(func() {
|
runsOnSystemdOnce.Do(func() {
|
||||||
initCommand, err := os.ReadFile("/proc/1/comm")
|
// per sd_booted(3), check for this dir
|
||||||
// On errors, default to systemd
|
fd, err := os.Stat("/run/systemd/system")
|
||||||
runsOnSystemd = err != nil || strings.TrimRight(string(initCommand), "\n") == "systemd"
|
runsOnSystemd = err == nil && fd.IsDir()
|
||||||
})
|
})
|
||||||
return runsOnSystemd
|
return runsOnSystemd
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user