diff --git a/cmd/cmd.go b/cmd/cmd.go index 0c79f7ea8..9ada78a57 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -303,6 +303,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) { if showStats { stopStats = StartStats() } + SigInfoHandler() for try := 1; try <= *retries; try++ { err = f() if !Retry || (err == nil && !accounting.Stats.Errored()) { diff --git a/cmd/siginfo_darwin.go b/cmd/siginfo_darwin.go new file mode 100644 index 000000000..27e6c58de --- /dev/null +++ b/cmd/siginfo_darwin.go @@ -0,0 +1,23 @@ +//+build darwin + +package cmd + +import ( + "log" + "os" + "os/signal" + "syscall" + + "github.com/ncw/rclone/fs/accounting" +) + +// SigInfoHandler creates SigInfo handler +func SigInfoHandler() { + signals := make(chan os.Signal, 1) + signal.Notify(signals, syscall.SIGINFO) + go func() { + for range signals { + log.Printf("%v\n", accounting.Stats) + } + }() +} diff --git a/cmd/siginfo_others.go b/cmd/siginfo_others.go new file mode 100644 index 000000000..d1c878e27 --- /dev/null +++ b/cmd/siginfo_others.go @@ -0,0 +1,7 @@ +//+build !darwin + +package cmd + +// SigInfoHandler creates SigInfo handler +func SigInfoHandler() { +}