mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Implement review suggestion
This commit is contained in:
parent
196049a040
commit
6a1c282491
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -34,10 +35,16 @@ func checkAndCreateInstanceLock(name string) (pid int32, err error) {
|
||||||
|
|
||||||
// Check if process exists.
|
// Check if process exists.
|
||||||
p, err := processInfo.NewProcess(int32(parsedPid))
|
p, err := processInfo.NewProcess(int32(parsedPid))
|
||||||
if err != nil {
|
switch {
|
||||||
|
case err == nil:
|
||||||
|
// Process exists, continue.
|
||||||
|
case errors.Is(err, processInfo.ErrorProcessNotRunning):
|
||||||
// A process with the locked PID does not exist.
|
// A process with the locked PID does not exist.
|
||||||
// This is expected, so we can continue normally.
|
// This is expected, so we can continue normally.
|
||||||
return 0, createInstanceLock(lockFilePath)
|
return 0, createInstanceLock(lockFilePath)
|
||||||
|
default:
|
||||||
|
// There was an internal error getting the process.
|
||||||
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the process paths and evaluate and clean them.
|
// Get the process paths and evaluate and clean them.
|
||||||
|
|
Loading…
Add table
Reference in a new issue