go-zero/core/fs/files.go
2025-01-28 11:11:49 +08:00

16 lines
238 B
Go

//go:build linux || darwin || freebsd
package fs
import (
"os"
"syscall"
)
// CloseOnExec makes sure closing the file on process forking.
func CloseOnExec(file *os.File) {
if file != nil {
syscall.CloseOnExec(int(file.Fd()))
}
}