Use CLOEXEC with openat

This commit is contained in:
Kovid Goyal 2026-04-21 22:01:39 +05:30
parent 43035b7224
commit b4f7162a73
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -48,7 +48,7 @@ func openAt(dirFile *os.File, name string, flags int, perm os.FileMode) (*os.Fil
dirFd := int(dirFile.Fd())
// Call the underlying system call
fd, err := unix.Openat(dirFd, name, flags, uint32(perm))
fd, err := unix.Openat(dirFd, name, flags|unix.O_CLOEXEC, uint32(perm))
if err != nil {
return nil, &os.PathError{Op: "openat", Path: name, Err: err}
}