diff options
author | Ruben Pollan <meskio@sindominio.net> | 2019-06-13 12:15:08 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2019-06-13 12:15:08 +0200 |
commit | a9ab5e74832545b7914fbbda45b97db10c8e9265 (patch) | |
tree | cc4a07087f59d998643f3f4a930f40d35a4c6b76 | |
parent | 56d79a60679ba3783dcb5dd1ebe69436c5e5af7c (diff) |
[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
-rw-r--r-- | pkg/systray/run.go | 7 |
1 files 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) } |