diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-03-13 20:59:14 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@google.com> | 2023-03-15 17:21:30 +0000 |
| commit | f5eef58e4381259cbd84b3f2074c79607fb5c821 (patch) | |
| tree | 1405152029a813b5e8efa81c1cd10212a6eb12a0 /src/syscall/syscall_linux_loong64.go | |
| parent | 491153a71ab2bae3fe9a586489320573448511ab (diff) | |
| download | go-f5eef58e4381259cbd84b3f2074c79607fb5c821.tar.xz | |
syscall: restore original NOFILE rlimit in child process
If we increased the NOFILE rlimit when starting the program,
restore the original rlimit when forking a child process.
For #46279
Change-Id: Ia5d2af9ef435e5932965c15eec2e428d2130d230
Reviewed-on: https://go-review.googlesource.com/c/go/+/476097
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/syscall/syscall_linux_loong64.go')
| -rw-r--r-- | src/syscall/syscall_linux_loong64.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/syscall/syscall_linux_loong64.go b/src/syscall/syscall_linux_loong64.go index 5a0fa0834d..f8f01c2d22 100644 --- a/src/syscall/syscall_linux_loong64.go +++ b/src/syscall/syscall_linux_loong64.go @@ -187,11 +187,17 @@ func Getrlimit(resource int, rlim *Rlimit) error { return prlimit(0, resource, nil, rlim) } -// Setrlimit prefers the prlimit64 system call. -func Setrlimit(resource int, rlim *Rlimit) error { +// setrlimit prefers the prlimit64 system call. +func setrlimit(resource int, rlim *Rlimit) error { return prlimit(0, resource, rlim, nil) } +//go:nosplit +func rawSetrlimit(resource int, rlim *Rlimit) Errno { + _, _, errno := RawSyscall6(SYS_PRLIMIT64, 0, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0, 0, 0) + return errno +} + func (r *PtraceRegs) GetEra() uint64 { return r.Era } func (r *PtraceRegs) SetEra(era uint64) { r.Era = era } |
