fix(unlock cmd): ignore process if its the current id (#360)

This commit is contained in:
Florian 2024-03-13 12:39:51 +01:00 committed by GitHub
parent edb3ba35d8
commit dc56911a45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package cmd
import (
"bytes"
"fmt"
"os"
"os/exec"
"strings"
@ -61,9 +62,10 @@ func isAutoresticRunning() bool {
lines := strings.Split(out.String(), "\n")
autoresticProcesses := []string{}
currentPid := fmt.Sprint(os.Getpid())
for _, line := range lines {
if strings.Contains(line, "autorestic") && !strings.Contains(line, "grep autorestic") {
if strings.Contains(line, "autorestic") && !strings.Contains(line, "grep autorestic") && !strings.Contains(line, currentPid) {
autoresticProcesses = append(autoresticProcesses, line)
}
}