func (c *UnixConn) readMsg(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err error) {
var sa syscall.Sockaddr
n, oobn, flags, sa, err = c.fd.readMsg(b, oob, readMsgFlags)
- if oobn > 0 {
+ if readMsgFlags == 0 && err == nil && oobn > 0 {
setReadMsgCloseOnExec(oob[:oobn])
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris
-// +build aix darwin dragonfly freebsd netbsd openbsd solaris
+//go:build aix || darwin || freebsd || solaris
+// +build aix darwin freebsd solaris
package net
-import (
- "syscall"
-)
+import "syscall"
const readMsgFlags = 0
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build linux
-// +build linux
+//go:build dragonfly || linux || netbsd || openbsd
+// +build dragonfly linux netbsd openbsd
package net
-import (
- "syscall"
-)
+import "syscall"
const readMsgFlags = syscall.MSG_CMSG_CLOEXEC
-func setReadMsgCloseOnExec(oob []byte) {
-}
+func setReadMsgCloseOnExec(oob []byte) {}
const readMsgFlags = 0
-func setReadMsgCloseOnExec(oob []byte) {
-}
+func setReadMsgCloseOnExec(oob []byte) {}
MAP_VPAGETABLE = 0x2000
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
+ MSG_CMSG_CLOEXEC = 0x1000
MSG_CTRUNC = 0x20
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x80
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
MSG_BCAST = 0x100
+ MSG_CMSG_CLOEXEC = 0x800
MSG_CTRUNC = 0x20
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x80
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
MSG_BCAST = 0x100
+ MSG_CMSG_CLOEXEC = 0x800
MSG_CTRUNC = 0x20
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x80