github.com/zaquestion/lab@v0.25.1/cmd/util_linux.go (about) 1 // This file contains Linux specific calls. 2 3 package cmd 4 5 // Since we're using some system calls that are platform-specific, we need 6 // to make sure we have a small layer of compatibility for Linux, Windows 7 // and *BSD operating systems. 8 9 import "syscall" 10 11 // We're using the Linux API as primary model, hence we can only return 12 // the results from the default syscalls. 13 14 var ( 15 sysStdout = syscall.Stdout 16 sysStderr = syscall.Stderr 17 ) 18 19 func closeFD(fd int) error { 20 return syscall.Close(fd) 21 } 22 23 func dupFD(fd int) (int, error) { 24 return syscall.Dup(fd) 25 } 26 27 // Dup2() is not supported in Linux arm64, so we need to change it. 28 // Dup3() is available in all Linux arches and BSD* variants, but not darwin. 29 func dupFD2(newFD, oldFD int) error { 30 return syscall.Dup3(newFD, oldFD, 0) 31 }