Skip to content

Commit

Permalink
set RLIMIT_NOFILE soft limit to match the hard limit on mac
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Signed-off-by: Sam Peterson <[email protected]>
  • Loading branch information
SamInTheShell committed Nov 10, 2023
1 parent d7d8b86 commit 5e0471b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions cmd/podman/early_init_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"os"
"syscall"
)

func setRLimitsNoFile() error {
var rLimitNoFile syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimitNoFile); err != nil {
return fmt.Errorf("getting RLIMITS_NOFILE: %w", err)
}
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{
Max: rLimitNoFile.Max,
Cur: rLimitNoFile.Max,
})
if err != nil {
return fmt.Errorf("setting new RLIMITS_NOFILE: %w", err)
}
return nil
}

func earlyInitHook() {
if err := setRLimitsNoFile(); err != nil {
fmt.Fprintf(os.Stderr, "Failed to set RLIMITS_NOFILE: %s\n", err.Error())
}
}
4 changes: 2 additions & 2 deletions cmd/podman/early_init_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux
// +build !linux
//go:build !linux && !darwin
// +build !linux,!darwin

package main

Expand Down

0 comments on commit 5e0471b

Please sign in to comment.