feat: merge pull request #23 from burakgizlice/fix/stale-pid-detection

fix: detect stale PID files from recycled PIDs
This commit is contained in:
Leonardo Trapani
2026-02-17 09:20:02 +01:00
committed by GitHub
+14
View File
@@ -8,6 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings"
"syscall" "syscall"
) )
@@ -99,6 +100,19 @@ func (pm *pidManager) isProcessAlive(pid int) bool {
return false return false
} }
// Verify the process is actually hyprvoice and not a recycled PID
cmdline, err := os.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid))
if err != nil {
log.Printf("Process %d alive but cannot read cmdline, assuming stale: %v", pid, err)
return false
}
exe := string(cmdline)
if len(exe) == 0 || !strings.Contains(exe, "hyprvoice") {
log.Printf("Process %d is alive but is not hyprvoice (cmdline: %q), stale PID file", pid, exe)
return false
}
return true return true
} }