diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-04 21:36:18 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-04 21:36:18 +0800 |
commit | a0916048f7cccab1b83530d4bc3cd14e63c4dba3 (patch) | |
tree | bba26b7ffc857031df104f52ab930de8f33312b5 /misc | |
parent | misc: Wrap_one_error (diff) | |
download | go-lindenii-common-a0916048f7cccab1b83530d4bc3cd14e63c4dba3.tar.gz go-lindenii-common-a0916048f7cccab1b83530d4bc3cd14e63c4dba3.tar.zst go-lindenii-common-a0916048f7cccab1b83530d4bc3cd14e63c4dba3.zip |
misc: O_CLOEXEC to all open-related syscalls
Diffstat (limited to 'misc')
-rw-r--r-- | misc/open_file.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/misc/open_file.go b/misc/open_file.go index 2ee53db..5bc6067 100644 --- a/misc/open_file.go +++ b/misc/open_file.go @@ -29,7 +29,7 @@ func Open_file_at(dir Dir_t, filename string, flags int, perms os.FileMode) (*os // Open a file at or beneath the given directory. func Open_file_beneath(dir Dir_t, filename string, flags int, perms os.FileMode) (*os.File, error) { fd, err := Openat2(dir.fd, filename, &Open_how_t{ - Flags: uint64(flags), + Flags: uint64(flags)|syscall.O_CLOEXEC, Mode: uint64(syscallMode(perms)), Resolve: RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS, }) @@ -47,7 +47,7 @@ func Open_file_beneath(dir Dir_t, filename string, flags int, perms os.FileMode) // Open a directory as read-only and return a Dir_t to it. The caller is // responsible for closing the directory with [Close_directory]. func Open_directory_readonly(path string) (Dir_t, error) { - _fd, err := syscall.Open(path, os.O_RDONLY|syscall.O_DIRECTORY, 0) + _fd, err := syscall.Open(path, syscall.O_RDONLY|syscall.O_DIRECTORY|syscall.O_CLOEXEC, 0) return Dir_t{fd: _fd, name: path}, err } |