From a9ab5e74832545b7914fbbda45b97db10c8e9265 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 13 Jun 2019 12:15:08 +0200 Subject: [bug] wait for tear down Before finishing the main thread let's wait for the finish of the bitmask/pid/... tear down. So the firewall gets down when you ctrl-c. - Resolves: #142 --- pkg/systray/run.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/systray/run.go b/pkg/systray/run.go index d9d39de..ce4a886 100644 --- a/pkg/systray/run.go +++ b/pkg/systray/run.go @@ -25,11 +25,14 @@ import ( func Run(conf *Config) { bt := bmTray{conf: conf, waitCh: make(chan bool)} - go initialize(conf, &bt) + finishedCh := make(chan bool) + go initialize(conf, &bt, finishedCh) bt.start() + <-finishedCh } -func initialize(conf *Config, bt *bmTray) { +func initialize(conf *Config, bt *bmTray, finishedCh chan bool) { + defer func() { finishedCh <- true }() if _, err := os.Stat(config.Path); os.IsNotExist(err) { os.MkdirAll(config.Path, os.ModePerm) } -- cgit v1.2.3