From 5b6bb5ced2ef2c359202b3c2aa1721c3c7f0d6b2 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 15 Sep 2020 22:30:32 +0200 Subject: [bug] accept corrupted pid files A corrupted pid file, or a file that contains something else than a pid number used to block bitmask-vpn from launch. Now if the file contains something that is not expected it will log it and rewrite it. I refactor de code so the pid file will be released on quit instead of initialization. - Resolves: #349 --- pkg/backend/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/backend/init.go') diff --git a/pkg/backend/init.go b/pkg/backend/init.go index aabc720..c0d8f37 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -7,6 +7,7 @@ import ( "0xacab.org/leap/bitmask-vpn/pkg/bitmask" "0xacab.org/leap/bitmask-vpn/pkg/config" "0xacab.org/leap/bitmask-vpn/pkg/config/version" + "0xacab.org/leap/bitmask-vpn/pkg/pid" ) // initializeContext initializes an empty connStatus and assigns it to the @@ -52,6 +53,13 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { bitmask.InitializeLogger() ctx.cfg = config.ParseConfig() + err := pid.AcquirePID() + if err != nil { + log.Println("Error acquiring PID:", err) + errCh <- err.Error() + return + } + b, err := bitmask.InitializeBitmask(opts.SkipLaunch) if err != nil { log.Println("error: cannot initialize bitmask") -- cgit v1.2.3