From 87db3cfad38260e06fa81f8c32c6c1679880e7bd Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Wed, 7 Sep 2016 22:21:58 +0200 Subject: [PATCH] Use Dup2 library function instead of raw syscall The Dup2 syscall does not exist on 64-bit arm Linux while its replacement Dup3 does not exist on non-Linux systems. Using the unix.Dup2 library function instead of raw syscalls improves the portability across more platforms. --- cmd/redirect_stderr_unix.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/redirect_stderr_unix.go b/cmd/redirect_stderr_unix.go index f31c8e062..bc1177ad3 100644 --- a/cmd/redirect_stderr_unix.go +++ b/cmd/redirect_stderr_unix.go @@ -7,12 +7,13 @@ package cmd import ( "log" "os" - "syscall" + + "golang.org/x/sys/unix" ) // redirectStderr to the file passed in func redirectStderr(f *os.File) { - err := syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd())) + err := unix.Dup2(int(f.Fd()), int(os.Stderr.Fd())) if err != nil { log.Fatalf("Failed to redirect stderr to file: %v", err) }