Commit 047a3265 authored by Baokun Lee's avatar Baokun Lee Committed by Ian Lance Taylor

[release-branch.go1.12] os: enable the close-on-exec flag for openFdAt

There's a race here with fork/exec, enable the close-on-exec flag
for the new file descriptor.

Updates #33405
Fixes #33424

Change-Id: Ib1e405c3b48b11c867f183fd13eff8b73d95e3b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/188537
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
(cherry picked from commit 2d6ee6e8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/188538
Run-TryBot: Ian Lance Taylor <iant@golang.org>
parent 3c977973
...@@ -157,7 +157,7 @@ func openFdAt(dirfd int, name string) (*File, error) { ...@@ -157,7 +157,7 @@ func openFdAt(dirfd int, name string) (*File, error) {
var r int var r int
for { for {
var e error var e error
r, e = unix.Openat(dirfd, name, O_RDONLY, 0) r, e = unix.Openat(dirfd, name, O_RDONLY|syscall.O_CLOEXEC, 0)
if e == nil { if e == nil {
break break
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment