mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 17:14:44 +01:00
87db3cfad3
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.
21 lines
378 B
Go
21 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)
|
|
}
|
|
}
|