files.go 223 B

123456789101112131415
  1. // +build linux darwin
  2. package fs
  3. import (
  4. "os"
  5. "syscall"
  6. )
  7. // CloseOnExec makes sure closing the file on process forking.
  8. func CloseOnExec(file *os.File) {
  9. if file != nil {
  10. syscall.CloseOnExec(int(file.Fd()))
  11. }
  12. }