Source file
src/syscall/sock_cloexec_linux.go
1
2
3
4
5 package syscall
6
7
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:
16 }
17
18 ForkLock.RLock()
19 s, err = Socket(family, sotype, proto)
20 if err == nil {
21 CloseOnExec(s)
22 }
23 ForkLock.RUnlock()
24 if err != nil {
25 Close(s)
26 return -1, err
27 }
28 return s, nil
29 }
30
View as plain text