package syscall
import (
+ "runtime"
"unsafe"
)
// Pass 1: look for fd[i] < i and move those up above len(fd)
// so that pass 2 won't stomp on an fd it needs later.
if pipe < nextfd {
- _, err1 = dup2child(uintptr(pipe), uintptr(nextfd))
+ switch runtime.GOOS {
+ case "illumos":
+ _, err1 = fcntl1(uintptr(pipe), _F_DUP2FD_CLOEXEC, uintptr(nextfd))
+ default:
+ _, err1 = dup2child(uintptr(pipe), uintptr(nextfd))
+ if err1 != 0 {
+ goto childerror
+ }
+ _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC)
+ }
if err1 != 0 {
goto childerror
}
- fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC)
pipe = nextfd
nextfd++
}
if nextfd == pipe { // don't stomp on pipe
nextfd++
}
- _, err1 = dup2child(uintptr(fd[i]), uintptr(nextfd))
- if err1 != 0 {
- goto childerror
+ switch runtime.GOOS {
+ case "illumos":
+ _, err1 = fcntl1(uintptr(fd[i]), _F_DUP2FD_CLOEXEC, uintptr(nextfd))
+ default:
+ _, err1 = dup2child(uintptr(fd[i]), uintptr(nextfd))
+ if err1 != 0 {
+ goto childerror
+ }
+ _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC)
}
- _, err1 = fcntl1(uintptr(nextfd), F_SETFD, FD_CLOEXEC)
if err1 != 0 {
goto childerror
}
import "unsafe"
+const _F_DUP2FD_CLOEXEC = F_DUP2FD_CLOEXEC
+
// Implemented in asm_solaris_amd64.s.
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)