Implement review suggestion
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user