Source file
src/net/sys_cloexec.go
1
2
3
4
5
6
7
8
9
10 package net
11
12 import (
13 "internal/poll"
14 "os"
15 "syscall"
16 )
17
18
19
20 func sysSocket(family, sotype, proto int) (int, error) {
21
22 syscall.ForkLock.RLock()
23 s, err := socketFunc(family, sotype, proto)
24 if err == nil {
25 syscall.CloseOnExec(s)
26 }
27 syscall.ForkLock.RUnlock()
28 if err != nil {
29 return -1, os.NewSyscallError("socket", err)
30 }
31 if err = syscall.SetNonblock(s, true); err != nil {
32 poll.CloseFunc(s)
33 return -1, os.NewSyscallError("setnonblock", err)
34 }
35 return s, nil
36 }
37
View as plain text