Skip to content

Commit

Permalink
syscall/prlimit: fix a clear nofile limit cache error in syscall.prlimit
Browse files Browse the repository at this point in the history
Fixes: #67184
The syscall unix.Prlimit can set other process's nofile limit, if we do
that, we should not clear the calling process's nofile rlimit cache.

Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information
lifubang committed May 5, 2024
1 parent 20130cc commit 840b5e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/syscall/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ func Munmap(b []byte) (err error) {
// This is unexported but can be called from x/sys/unix.
func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
err = prlimit1(pid, resource, newlimit, old)
if err == nil && newlimit != nil && resource == RLIMIT_NOFILE {
if err == nil && newlimit != nil && resource == RLIMIT_NOFILE && (pid == 0 || pid == Getpid()) {
origRlimitNofile.Store(nil)
}
return err
Expand Down

0 comments on commit 840b5e2

Please sign in to comment.