This commit is contained in:
Zoltán Papp
2026-03-02 14:12:53 +01:00
parent 9a6a72e88e
commit 04a982263d
89 changed files with 8147 additions and 22 deletions

View File

@@ -0,0 +1,25 @@
//go:build !windows
package process
import (
"os"
"github.com/shirou/gopsutil/v3/process"
log "github.com/sirupsen/logrus"
)
func isProcessOwnedByCurrentUser(p *process.Process) bool {
currentUserID := os.Getuid()
uids, err := p.Uids()
if err != nil {
log.Errorf("get process uids: %v", err)
return false
}
for _, id := range uids {
if int(id) == currentUserID {
return true
}
}
return false
}