aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_libc2.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall/exec_libc2.go')
-rw-r--r--src/syscall/exec_libc2.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/syscall/exec_libc2.go b/src/syscall/exec_libc2.go
index 9eb61a5d35..499a5deb7e 100644
--- a/src/syscall/exec_libc2.go
+++ b/src/syscall/exec_libc2.go
@@ -62,6 +62,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
i int
)
+ rlim, rlimOK := origRlimitNofile.Load().(Rlimit)
+
// guard against side effects of shuffling fds below.
// Make sure that nextfd is beyond any currently open files so
// that we can't run the risk of overwriting any of them.
@@ -266,6 +268,11 @@ 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)
+ }
+
// Time to exec.
_, _, err1 = rawSyscall(abi.FuncPCABI0(libc_execve_trampoline),
uintptr(unsafe.Pointer(argv0)),