github.com/zaquestion/lab@v0.25.1/cmd/util_bsd.go (about) 1 // This file contains Darwin (MacOS) and *BSD specific calls. 2 3 //go:build freebsd || openbsd || dragonfly || darwin 4 // +build freebsd openbsd dragonfly darwin 5 6 package cmd 7 8 // Unfortunatelly MacOS don't have the DUP3() system call, which is forced 9 // by Linux ARM64 not having the DUP2() anymore. With that, we need to 10 // repeat the other code and func declarations that are the same. 11 12 // FIXME: there MUST be some better way to do that... only dupFD2() should 13 // be here. 14 15 import "syscall" 16 17 var ( 18 sysStdout = syscall.Stdout 19 sysStderr = syscall.Stderr 20 ) 21 22 func closeFD(fd int) error { 23 return syscall.Close(fd) 24 } 25 26 func dupFD(fd int) (int, error) { 27 return syscall.Dup(fd) 28 } 29 30 // From what I've seen, darwin is the only OS without DUP3() support 31 func dupFD2(newFD, oldFD int) error { 32 return syscall.Dup2(newFD, oldFD) 33 }