-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20643 from protosam/main
fix max open files limit for qemu
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|