mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19: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
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -34,10 +35,16 @@ func checkAndCreateInstanceLock(name string) (pid int32, err error) {
|
|||
|
||||
// Check if process exists.
|
||||
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.
|
||||
// This is expected, so we can continue normally.
|
||||
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue