net, syscall: use accept4 and SOCK_CLOEXEC on Linux

R=golang-dev, bradfitz, mikioh.mikioh, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7227043
This commit is contained in:
Ian Lance Taylor 2013-01-28 08:54:15 -08:00
parent b53e95ac2e
commit 31f58dce67
11 changed files with 179 additions and 17 deletions

View file

@ -20,6 +20,10 @@ func newFileFD(f *os.File) (*netFD, error) {
}
syscall.CloseOnExec(fd)
syscall.ForkLock.RUnlock()
if err = syscall.SetNonblock(fd, true); err != nil {
closesocket(fd)
return nil, err
}
sotype, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_TYPE)
if err != nil {