// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package syscall

// This is a stripped down version of sysSocket from net/sock_cloexec.go.
func (, ,  int) (int, error) {
	,  := Socket(, |SOCK_CLOEXEC, )
	switch  {
	case nil:
		return , nil
	default:
		return -1, 
	case EINVAL:
	}

	ForkLock.RLock()
	,  = Socket(, , )
	if  == nil {
		CloseOnExec()
	}
	ForkLock.RUnlock()
	if  != nil {
		Close()
		return -1, 
	}
	return , nil
}