mirror of
https://github.com/rclone/rclone.git
synced 2025-06-25 14:31:39 +02:00
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.
This commit is contained in:
parent
54fdc6866e
commit
87db3cfad3
@ -7,12 +7,13 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// redirectStderr to the file passed in
|
// redirectStderr to the file passed in
|
||||||
func redirectStderr(f *os.File) {
|
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 {
|
if err != nil {
|
||||||
log.Fatalf("Failed to redirect stderr to file: %v", err)
|
log.Fatalf("Failed to redirect stderr to file: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user