mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-08 17:00:13 +08:00

Go 1.23 tightens access to internal symbols, and even puts runc into
"hall of shame" for using an internal symbol (recently added by commit
da68c8e3
). So, while not impossible, it becomes harder to access those
internal symbols, and it is a bad idea in general.
Since Go 1.23 includes https://go.dev/cl/588076, we can clean the
internal rlimit cache by setting the RLIMIT_NOFILE for ourselves,
essentially disabling the rlimit cache.
Once Go 1.22 is no longer supported, we will remove the go:linkname hack.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
16 lines
435 B
Go
16 lines
435 B
Go
//go:build go1.23
|
|
|
|
package system
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
// ClearRlimitNofileCache clears go runtime's nofile rlimit cache. The argument
|
|
// is process RLIMIT_NOFILE values. Relies on go.dev/cl/588076.
|
|
func ClearRlimitNofileCache(lim *syscall.Rlimit) {
|
|
// Ignore the return values since we only need to clean the cache,
|
|
// the limit is going to be set via unix.Prlimit elsewhere.
|
|
_ = syscall.Setrlimit(syscall.RLIMIT_NOFILE, lim)
|
|
}
|