mirror of
https://github.com/golang/go
synced 2024-11-23 16:30:06 -07:00
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. Fixes #33405 Change-Id: If95bae97a52b7026a930bb3427e47bae3b0032ac 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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e7c51cad71
commit
2d6ee6e89a
@ -173,7 +173,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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user