mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
Merge pull request #6786 from rhafer/rootless_rlimit
specgen: fix order for setting rlimits
This commit is contained in:
@ -52,10 +52,14 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) error {
|
||||
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||
logrus.Warnf("failed to return RLIMIT_NOFILE ulimit %q", err)
|
||||
}
|
||||
current = rlimit.Cur
|
||||
max = rlimit.Max
|
||||
if rlimit.Cur < current {
|
||||
current = rlimit.Cur
|
||||
}
|
||||
if rlimit.Max < max {
|
||||
max = rlimit.Max
|
||||
}
|
||||
}
|
||||
g.AddProcessRlimits("RLIMIT_NOFILE", current, max)
|
||||
g.AddProcessRlimits("RLIMIT_NOFILE", max, current)
|
||||
}
|
||||
if !nprocSet {
|
||||
max := kernelMax
|
||||
@ -65,10 +69,14 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) error {
|
||||
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
|
||||
logrus.Warnf("failed to return RLIMIT_NPROC ulimit %q", err)
|
||||
}
|
||||
current = rlimit.Cur
|
||||
max = rlimit.Max
|
||||
if rlimit.Cur < current {
|
||||
current = rlimit.Cur
|
||||
}
|
||||
if rlimit.Max < max {
|
||||
max = rlimit.Max
|
||||
}
|
||||
}
|
||||
g.AddProcessRlimits("RLIMIT_NPROC", current, max)
|
||||
g.AddProcessRlimits("RLIMIT_NPROC", max, current)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user