Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

638 B
Raw Blame
// Log the panic under unix to the log file

//go:build !windows && !solaris && !plan9 && !js

package log

import (
	"os"

	"github.com/rclone/rclone/fs"
	"github.com/rclone/rclone/fs/config"
	"golang.org/x/sys/unix"
)

// redirectStderr to the file passed in
func redirectStderr(f *os.File) {
	passPromptFd, err := unix.Dup(int(os.Stderr.Fd()))
	if err != nil {
		fs.Fatalf(nil, "Failed to duplicate stderr: %v", err)
	}
	config.PasswordPromptOutput = os.NewFile(uintptr(passPromptFd), "passPrompt")
	err = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
	if err != nil {
		fs.Fatalf(nil, "Failed to redirect stderr to file: %v", err)
	}
}