aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_bsd.go
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2023-09-29 06:06:40 +0000
committerGopher Robot <gobot@golang.org>2023-09-29 18:51:35 +0000
commitfa4f951026f697bc042422d95a0806dcbab7ddd0 (patch)
tree865225530fef2c5c87c9a077c1b386d1363bd44d /src/syscall/exec_bsd.go
parent9bfaaa15fd38f10ba7f11eb6cc67c6dfb21454e6 (diff)
downloadgo-fa4f951026f697bc042422d95a0806dcbab7ddd0.tar.xz
syscall: make origRlimitNofile atomic.Pointer[Rlimit]
Currently we are bootstrapping with Go 1.20, origRlimitNofile can be changed to atomic.Pointer[Rlimit]. Change-Id: I00ce9d1a9030bd5dbd34e3dc6c4e38683a87be86 GitHub-Last-Rev: f2ccdb38412019d10661ed6be42086b445e411bf GitHub-Pull-Request: golang/go#63274 Reviewed-on: https://go-review.googlesource.com/c/go/+/531516 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/syscall/exec_bsd.go')
-rw-r--r--src/syscall/exec_bsd.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go
index 0b0cd24e69..149cc2f11c 100644
--- a/src/syscall/exec_bsd.go
+++ b/src/syscall/exec_bsd.go
@@ -64,7 +64,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
ngroups, groups uintptr
)
- rlim, rlimOK := origRlimitNofile.Load().(Rlimit)
+ rlim := origRlimitNofile.Load()
// guard against side effects of shuffling fds below.
// Make sure that nextfd is beyond any currently open files so
@@ -276,8 +276,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
// Restore original rlimit.
- if rlimOK && rlim.Cur != 0 {
- RawSyscall(SYS_SETRLIMIT, uintptr(RLIMIT_NOFILE), uintptr(unsafe.Pointer(&rlim)), 0)
+ if rlim != nil {
+ RawSyscall(SYS_SETRLIMIT, uintptr(RLIMIT_NOFILE), uintptr(unsafe.Pointer(rlim)), 0)
}
// Time to exec.