github.com/shuguocloud/go-zero@v1.3.0/core/fs/files.go (about) 1 //go:build linux || darwin 2 // +build linux darwin 3 4 package fs 5 6 import ( 7 "os" 8 "syscall" 9 ) 10 11 // CloseOnExec makes sure closing the file on process forking. 12 func CloseOnExec(file *os.File) { 13 if file != nil { 14 syscall.CloseOnExec(int(file.Fd())) 15 } 16 }