8000 cmd: add siginfo handler · devdevmac/rclone@de8c7d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit de8c7d8

Browse files
kubatasiemskincw
authored andcommitted
cmd: add siginfo handler
1 parent 2a29f7f commit de8c7d8

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

cmd/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
303303
if showStats {
304304
stopStats = StartStats()
305305
}
306+
SigInfoHandler()
306307
for try := 1; try <= *retries; try++ {
307308
err = f()
308309
if !Retry || (err == nil && !accounting.Stats.Errored()) {

cmd/siginfo_darwin.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//+build darwin
2+
3+
package cmd
4+
5+
import (
6+
"log"
7+
"os"
8+
"os/signal"
9+
"syscall"
10+
11+
"github.com/ncw/rclone/fs/accounting"
12+
)
13+
14+
// SigInfoHandler creates SigInfo handler
15+
func SigInfoHandler() {
16+
signals := make(chan os.Signal, 1)
17+
signal.Notify(signals, syscall.SIGINFO)
18+
go func() {
19+
for range signals {
20+
log.Printf("%v\n", accounting.Stats)
21+
}
22+
}()
23+
}

cmd/siginfo_others.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//+build !darwin
2+
3+
package cmd
4+
5+
// SigInfoHandler creates SigInfo handler
6+
func SigInfoHandler() {
7+
}

0 commit comments

Comments
 (0)
0