Skip to content

Commit

Permalink
Check return value of Setrlimit() to keep linter happy
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Reeves <[email protected]>
  • Loading branch information
chris-reeves committed Jun 20, 2024
1 parent 5241c92 commit 6646b57
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,16 @@ func addRlimits(ulimit []string, g *generate.Generator, defaultUlimits []string)
// process to RLimitDefaultValue - this will be successful in most (but not all)
// non-rootless environments. If this fails (e.g. in a rootless environment) it will ensure
// that the soft limit for the current process is increased to match the hard limit (see
// cmd/podman/early_init_linux.go). We simply fire and forget the call to Setrlimit() here,
// because if it fails we effectively handle setting soft to hard in the call to
// AddProcessRlimits() later on.
// cmd/podman/early_init_linux.go).
var rlimit unix.Rlimit
rlimit.Cur = define.RLimitDefaultValue
rlimit.Max = define.RLimitDefaultValue
unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
err := unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
if err != nil {
// We don't really care whether there's an error here, because if it fails we
// effectively handle setting soft to hard in the call to AddProcessRlimits() later on.
logrus.Debugf("Failed to set RLIMIT_NOFILE ulimit %q", err)
}

// Set both hard and soft limits to min(hard limit, RLimitDefaultValue) regardless of
// rootlessness.
Expand Down

0 comments on commit 6646b57

Please sign in to comment.