sys_darwin.go 768 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package os
  5. import "syscall"
  6. // supportsCloseOnExec reports whether the platform supports the
  7. // O_CLOEXEC flag.
  8. var supportsCloseOnExec bool
  9. func init() {
  10. // Seems like kern.osreldate is veiled on latest OS X. We use
  11. // kern.osrelease instead.
  12. osver, err := syscall.Sysctl("kern.osrelease")
  13. if err != nil {
  14. return
  15. }
  16. var i int
  17. for i = range osver {
  18. if osver[i] != '.' {
  19. continue
  20. }
  21. }
  22. // The O_CLOEXEC flag was introduced in OS X 10.7 (Darwin
  23. // 11.0.0). See http://support.apple.com/kb/HT1633.
  24. if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '1' {
  25. supportsCloseOnExec = true
  26. }
  27. }