go-zero/core/fs/files.go
2021-02-19 17:49:39 +08:00

16 lines
223 B
Go

// +build linux darwin
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()))
}
}