mirror of
https://github.com/containers/podman.git
synced 2025-06-24 11:28:24 +08:00
Merge pull request #7339 from giuseppe/change-systemd-detection
abi: fix detection for systemd
This commit is contained in:
@ -70,8 +70,13 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initCommand, err := ioutil.ReadFile("/proc/1/comm")
|
||||||
|
// On errors, default to systemd
|
||||||
|
runsUnderSystemd := err != nil || string(initCommand) == "systemd"
|
||||||
|
|
||||||
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
|
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
|
||||||
if conf.Engine.CgroupManager == config.SystemdCgroupsManager {
|
if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager {
|
||||||
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
|
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
|
||||||
logrus.Warnf("Failed to add podman to systemd sandbox cgroup: %v", err)
|
logrus.Warnf("Failed to add podman to systemd sandbox cgroup: %v", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user