diff options
| author | Ian Lance Taylor <iant@golang.org> | 2024-08-28 16:20:44 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-08-30 19:26:45 +0000 |
| commit | d0baac37e61648c2a9e9299553c863cf7b7eed61 (patch) | |
| tree | a930867938705097c3e0872a2339bda46de086e6 /src/syscall/syscall_linux.go | |
| parent | c2098929056481d0dc09f5f42b8959f4db8878f2 (diff) | |
| download | go-d0baac37e61648c2a9e9299553c863cf7b7eed61.tar.xz | |
syscall: always use prlimit for getrlimit/setrlimit on Linux
Linux added the prlimit system call in version 2.6.36.
As our minimum Linux kernel version is now 3.2,
simplify the various getrlimit/setlrimit implementations
to just always use prlimit.
For #67001
Change-Id: I2512c21c947d0bc83f8f9077c143163fd8d83be3
Reviewed-on: https://go-review.googlesource.com/c/go/+/609178
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/syscall/syscall_linux.go')
| -rw-r--r-- | src/syscall/syscall_linux.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index 032936398b..1fe422d691 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -1288,6 +1288,17 @@ func Munmap(b []byte) (err error) { //sys Mlockall(flags int) (err error) //sys Munlockall() (err error) +func Getrlimit(resource int, rlim *Rlimit) (err error) { + // prlimit1 is the same as prlimit when newlimit == nil + return prlimit1(0, resource, nil, rlim) +} + +// setrlimit sets a resource limit. +// The Setrlimit function is in rlimit.go, and calls this one. +func setrlimit(resource int, rlim *Rlimit) (err error) { + return prlimit(0, resource, rlim, nil) +} + // prlimit changes a resource limit. We use a single definition so that // we can tell StartProcess to not restore the original NOFILE limit. // |
