Source file
src/net/unixsock_readmsg_cloexec.go
1
2
3
4
5
6
7 package net
8
9 import "syscall"
10
11 const readMsgFlags = 0
12
13 func setReadMsgCloseOnExec(oob []byte) {
14 scms, err := syscall.ParseSocketControlMessage(oob)
15 if err != nil {
16 return
17 }
18
19 for _, scm := range scms {
20 if scm.Header.Level == syscall.SOL_SOCKET && scm.Header.Type == syscall.SCM_RIGHTS {
21 fds, err := syscall.ParseUnixRights(&scm)
22 if err != nil {
23 continue
24 }
25 for _, fd := range fds {
26 syscall.CloseOnExec(fd)
27 }
28 }
29 }
30 }
31
View as plain text