From fa4f951026f697bc042422d95a0806dcbab7ddd0 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Fri, 29 Sep 2023 06:06:40 +0000 Subject: 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 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: Than McIntosh --- src/syscall/exec_libc2.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/syscall/exec_libc2.go') diff --git a/src/syscall/exec_libc2.go b/src/syscall/exec_libc2.go index 4fca701d6b..7a67500844 100644 --- a/src/syscall/exec_libc2.go +++ b/src/syscall/exec_libc2.go @@ -65,7 +65,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 @@ -272,8 +272,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr } // Restore original rlimit. - if rlimOK && rlim.Cur != 0 { - rawSyscall(abi.FuncPCABI0(libc_setrlimit_trampoline), uintptr(RLIMIT_NOFILE), uintptr(unsafe.Pointer(&rlim)), 0) + if rlim != nil { + rawSyscall(abi.FuncPCABI0(libc_setrlimit_trampoline), uintptr(RLIMIT_NOFILE), uintptr(unsafe.Pointer(rlim)), 0) } // Time to exec. -- cgit v1.3