diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-09-16 12:14:02 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-09-17 10:37:59 +0200 |
commit | ae5a5b51b068f62c8ec71bb9ec555d2c5c5f4f37 (patch) | |
tree | 276d3c7d1297ff52224169413e1f2fe23c46a7ee /utils | |
parent | 34c9ce2ec91ac1ada9de0cc644f8870aaf190889 (diff) | |
download | podman-ae5a5b51b068f62c8ec71bb9ec555d2c5c5f4f37.tar.gz podman-ae5a5b51b068f62c8ec71bb9ec555d2c5c5f4f37.tar.bz2 podman-ae5a5b51b068f62c8ec71bb9ec555d2c5c5f4f37.zip |
system: always move pause process when running on systemd
when running on a systemd with systemd, always try to move the pause
process to its own scope.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit 9c1e27fdd536f6026efe3da4360755a3e9135ca8)
Diffstat (limited to 'utils')
-rw-r--r-- | utils/utils.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/utils.go b/utils/utils.go index 2e415130e..e2760d225 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,10 +4,12 @@ import ( "bytes" "fmt" "io" + "io/ioutil" "os" "os/exec" "strconv" "strings" + "sync" "github.com/containers/podman/v3/libpod/define" "github.com/containers/storage/pkg/archive" @@ -155,3 +157,18 @@ func RemoveScientificNotationFromFloat(x float64) (float64, error) { } return result, nil } + +var ( + runsOnSystemdOnce sync.Once + runsOnSystemd bool +) + +// RunsOnSystemd returns whether the system is using systemd +func RunsOnSystemd() bool { + runsOnSystemdOnce.Do(func() { + initCommand, err := ioutil.ReadFile("/proc/1/comm") + // On errors, default to systemd + runsOnSystemd = err != nil || strings.TrimRight(string(initCommand), "\n") == "systemd" + }) + return runsOnSystemd +} |