From: Baokun Lee Date: Thu, 1 Aug 2019 16:31:57 +0000 (+0800) Subject: [release-branch.go1.12] os: enable the close-on-exec flag for openFdAt X-Git-Tag: go1.12.9~5 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=047a326569a5d75c2f5c1fd49fccb4da623b038a;p=gostls13.git [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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor (cherry picked from commit 2d6ee6e89a4b30c7528d2977df4e1aa86651e4e4) Reviewed-on: https://go-review.googlesource.com/c/go/+/188538 Run-TryBot: Ian Lance Taylor --- diff --git a/src/os/removeall_at.go b/src/os/removeall_at.go index 330963b354..c7de8a32a8 100644 --- a/src/os/removeall_at.go +++ b/src/os/removeall_at.go @@ -157,7 +157,7 @@ func openFdAt(dirfd int, name string) (*File, error) { var r int for { 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 { break }