Home | History | Annotate | Download | only in os
      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 
      5 package os
      6 
      7 import "syscall"
      8 
      9 // supportsCloseOnExec reports whether the platform supports the
     10 // O_CLOEXEC flag.
     11 var supportsCloseOnExec bool
     12 
     13 func init() {
     14 	osrel, err := syscall.SysctlUint32("kern.osreldate")
     15 	if err != nil {
     16 		return
     17 	}
     18 	// The O_CLOEXEC flag was introduced in FreeBSD 8.3.
     19 	// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
     20 	if osrel >= 803000 {
     21 		supportsCloseOnExec = true
     22 	}
     23 }
     24