From 6646b573d651e8c8e9027bf7a7906979ee143591 Mon Sep 17 00:00:00 2001 From: Chris Reeves Date: Mon, 17 Jun 2024 21:34:15 +0100 Subject: [PATCH] Check return value of Setrlimit() to keep linter happy Signed-off-by: Chris Reeves --- run_linux.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/run_linux.go b/run_linux.go index a617629eeb3..79a9a324a60 100644 --- a/run_linux.go +++ b/run_linux.go @@ -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.