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_amd64.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_amd64.go')
| -rw-r--r-- | src/syscall/syscall_linux_amd64.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/syscall/syscall_linux_amd64.go b/src/syscall/syscall_linux_amd64.go index 77e1393de1..aa85a523b2 100644 --- a/src/syscall/syscall_linux_amd64.go +++ b/src/syscall/syscall_linux_amd64.go @@ -4,6 +4,10 @@ package syscall +import ( + "unsafe" +) + const ( _SYS_setgroups = SYS_SETGROUPS _SYS_clone3 = 435 @@ -33,7 +37,7 @@ const ( //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys Setfsgid(gid int) (err error) //sys Setfsuid(uid int) (err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb setrlimit(resource int, rlim *Rlimit) (err error) = SYS_SETRLIMIT //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Statfs(path string, buf *Statfs_t) (err error) @@ -98,6 +102,12 @@ func Time(t *Time_t) (tt Time_t, err error) { //sys Utime(path string, buf *Utimbuf) (err error) //sys utimes(path string, times *[2]Timeval) (err error) +//go:nosplit +func rawSetrlimit(resource int, rlim *Rlimit) Errno { + _, _, errno := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + return errno +} + func setTimespec(sec, nsec int64) Timespec { return Timespec{Sec: sec, Nsec: nsec} } |
