summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/standalone/main.go1
-rw-r--r--pkg/systray/run.go7
-rw-r--r--pkg/systray/systray.go8
3 files changed, 13 insertions, 3 deletions
diff --git a/pkg/standalone/main.go b/pkg/standalone/main.go
index 6c267d6..4ac5776 100644
--- a/pkg/standalone/main.go
+++ b/pkg/standalone/main.go
@@ -68,6 +68,7 @@ func (b *Bitmask) GetStatusCh() <-chan string {
// Close the connection to bitmask
func (b *Bitmask) Close() {
+ log.Printf("Close: cleanup and vpn shutdown...")
b.StopVPN()
err := b.launch.close()
if err != nil {
diff --git a/pkg/systray/run.go b/pkg/systray/run.go
index 6521da6..5764b36 100644
--- a/pkg/systray/run.go
+++ b/pkg/systray/run.go
@@ -27,8 +27,13 @@ func Run(conf *Config) {
bt := bmTray{conf: conf, waitCh: make(chan bool)}
finishedCh := make(chan bool)
go initialize(conf, &bt, finishedCh)
+ go func() {
+ <-finishedCh
+ /* in osx, systray.Quit() halts the program */
+ bt.quit()
+ os.Exit(0)
+ }()
bt.start()
- <-finishedCh
}
func initialize(conf *Config, bt *bmTray, finishedCh chan bool) {
diff --git a/pkg/systray/systray.go b/pkg/systray/systray.go
index 708ee3b..714852d 100644
--- a/pkg/systray/systray.go
+++ b/pkg/systray/systray.go
@@ -57,6 +57,10 @@ func (bt *bmTray) start() {
systray.Run(bt.onReady, bt.onExit)
}
+func (bt *bmTray) quit() {
+ systray.Quit()
+}
+
func (bt *bmTray) onExit() {
log.Println("Closing systray")
}
@@ -146,10 +150,10 @@ func (bt *bmTray) loop(bm bitmask.Bitmask, notify *notificator, as bitmask.Autos
if err != nil {
log.Printf("Error disabling autostart: %v", err)
}
- systray.Quit()
+ /* we return and leave bt.quit() to the caller */
return
case <-signalCh:
- systray.Quit()
+ /* we return and leave bt.quit() to the caller */
return
case <-time.After(5 * time.Second):