Skip to content

Commit 2d6ee6e

Browse files
oioojianlancetaylor
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent e7c51ca commit 2d6ee6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/os/removeall_at.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func openFdAt(dirfd int, name string) (*File, error) {
173173
var r int
174174
for {
175175
var e error
176-
r, e = unix.Openat(dirfd, name, O_RDONLY, 0)
176+
r, e = unix.Openat(dirfd, name, O_RDONLY|syscall.O_CLOEXEC, 0)
177177
if e == nil {
178178
break
179179
}

0 commit comments

Comments
 (0)