go-zero/core/fs/files.go

16 lines
227 B
Go
Raw Normal View History

//go:build linux || darwin
2020-07-26 17:09:05 +08:00
package fs
import (
"os"
"syscall"
)
2021-02-19 17:49:39 +08:00
// CloseOnExec makes sure closing the file on process forking.
2020-07-26 17:09:05 +08:00
func CloseOnExec(file *os.File) {
if file != nil {
syscall.CloseOnExec(int(file.Fd()))
}
}