rclone/cmd/redirect_stderr_unix.go
Fredrik Fornwall 87db3cfad3 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.
2016-09-08 08:17:31 +01:00

20 lines
378 B
Go

// Log the panic under unix to the log file
// +build darwin dragonfly freebsd linux nacl netbsd openbsd
package cmd
import (
"log"
"os"
"golang.org/x/sys/unix"
)
// redirectStderr to the file passed in
func redirectStderr(f *os.File) {
err := unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
if err != nil {
log.Fatalf("Failed to redirect stderr to file: %v", err)
}
}