Skip to content

Commit

Permalink
Merge pull request #4282 from lifubang/fix-comment-ClearRlimitNofileC…
Browse files Browse the repository at this point in the history
…ache

Add a correct GoDoc format comment for ClearRlimitNofileCache
  • Loading branch information
AkihiroSuda committed May 16, 2024
2 parents 4e8cf27 + a35f7d8 commit 3d07cbc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libcontainer/system/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (
//go:linkname syscallOrigRlimitNofile syscall.origRlimitNofile
var syscallOrigRlimitNofile atomic.Pointer[syscall.Rlimit]

// As reported in issue #4195, the new version of go runtime(since 1.19)
// will cache rlimit-nofile. Before executing execve, the rlimit-nofile
// of the process will be restored with the cache. In runc, this will
// cause the rlimit-nofile setting by the parent process for the container
// to become invalid. It can be solved by clearing this cache. But
// unfortunately, go stdlib doesn't provide such function, so we need to
// link to the private var `origRlimitNofile` in package syscall to hack.
// ClearRlimitNofileCache is to clear go runtime's nofile rlimit cache.
func ClearRlimitNofileCache() {
// As reported in issue #4195, the new version of go runtime(since 1.19)
// will cache rlimit-nofile. Before executing execve, the rlimit-nofile
// of the process will be restored with the cache. In runc, this will
// cause the rlimit-nofile setting by the parent process for the container
// to become invalid. It can be solved by clearing this cache. But
// unfortunately, go stdlib doesn't provide such function, so we need to
// link to the private var `origRlimitNofile` in package syscall to hack.
syscallOrigRlimitNofile.Store(nil)
}

Expand Down

0 comments on commit 3d07cbc

Please sign in to comment.