Properly handle SIGHUP and SIGTERM (#305)
* Properly handle SIGHUP, SIGINT and SIGTERM * Do not handle SIGINT * Cancel current copy/move/delete operation * Better cancel current operation
This commit is contained in:
parent
933b49d095
commit
c49140ab36
17
app.go
17
app.go
@ -7,6 +7,8 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@ -34,11 +36,24 @@ func newApp() *app {
|
||||
ui := newUI()
|
||||
nav := newNav(ui.wins[0].h)
|
||||
|
||||
quitChan := make(chan bool, 1)
|
||||
|
||||
osChan := make(chan os.Signal, 1)
|
||||
signal.Notify(osChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-osChan
|
||||
nav.copyTotalChan <- -nav.copyTotal
|
||||
nav.moveTotalChan <- -nav.moveTotal
|
||||
nav.deleteTotalChan <- -nav.deleteTotal
|
||||
quitChan <- true
|
||||
return
|
||||
}()
|
||||
|
||||
return &app{
|
||||
ui: ui,
|
||||
nav: nav,
|
||||
ticker: new(time.Ticker),
|
||||
quitChan: make(chan bool, 1),
|
||||
quitChan: quitChan,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user