Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier"
[official-gcc.git] / libgo / go / syscall / sock_cloexec_linux.go
blob600cf25c150188e4254a2c477d81fbef3583133b
1 // Copyright 2019 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.
5 package syscall
7 // This is a stripped down version of sysSocket from net/sock_cloexec.go.
8 func cloexecSocket(family, sotype, proto int) (int, error) {
9 s, err := Socket(family, sotype|SOCK_CLOEXEC, proto)
10 switch err {
11 case nil:
12 return s, nil
13 default:
14 return -1, err
15 case EINVAL:
18 ForkLock.RLock()
19 s, err = Socket(family, sotype, proto)
20 if err == nil {
21 CloseOnExec(s)
23 ForkLock.RUnlock()
24 if err != nil {
25 Close(s)
26 return -1, err
28 return s, nil