Game detection: foreign GPU holders take an external lock hold (GAME_PROCS, GPU_FOREIGN_VRAM_MB)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
//go:build linux
|
||||
|
||||
package game
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// processes lists the running processes from /proc/<pid>/comm.
|
||||
func processes() ([]Process, error) {
|
||||
entries, err := os.ReadDir("/proc")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ps []Process
|
||||
for _, e := range entries {
|
||||
pid, err := strconv.Atoi(e.Name())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
comm, err := os.ReadFile("/proc/" + e.Name() + "/comm")
|
||||
if err != nil {
|
||||
continue // process vanished mid-walk
|
||||
}
|
||||
ps = append(ps, Process{PID: pid, Name: strings.TrimSpace(string(comm))})
|
||||
}
|
||||
return ps, nil
|
||||
}
|
||||
Reference in New Issue
Block a user