From: Martin Möhrmann Date: Sat, 18 Feb 2017 06:46:41 +0000 (+0100) Subject: os: remove incorrect detection of O_CLOEXEC flag on darwin X-Git-Tag: go1.9beta1~1507 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6ef92b6e3bce369feeb114dd3267a3f18038fc8c;p=gostls13.git os: remove incorrect detection of O_CLOEXEC flag on darwin The below range loop will not stop when encountering the first '.' character in a Darwin version string like "15.6.0". for i = range osver { if osver[i] != '.' { continue } } } Therefore, the condition i > 2 was always satisfied and supportsCloseOnExec was always set to true. Since the minimum supported version of OSX for go is currently 10.8 and O_CLOEXEC is implemented from OSX 10.7 on the detection code can be removed and support for O_CLOEXEC is always assumed to exist. Change-Id: Idd10094d8385dd4adebc8d7a6d9e9a8f29455867 Reviewed-on: https://go-review.googlesource.com/37193 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/os/sys_darwin.go b/src/os/sys_darwin.go index 7a8330abb5..11d678ef18 100644 --- a/src/os/sys_darwin.go +++ b/src/os/sys_darwin.go @@ -4,28 +4,8 @@ package os -import "syscall" - // supportsCloseOnExec reports whether the platform supports the // O_CLOEXEC flag. -var supportsCloseOnExec bool - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - osver, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - var i int - for i = range osver { - if osver[i] != '.' { - continue - } - } - // The O_CLOEXEC flag was introduced in OS X 10.7 (Darwin - // 11.0.0). See http://support.apple.com/kb/HT1633. - if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '1' { - supportsCloseOnExec = true - } -} +// The O_CLOEXEC flag was introduced in OS X 10.7 (Darwin 11.0.0). +// See http://support.apple.com/kb/HT1633. +const supportsCloseOnExec = true