1
0

[util.go] It is better to leave just cmdline actually.

This commit is contained in:
Alexander Andreev 2022-01-03 01:35:51 +04:00
parent cf300b899a
commit 33cebee08f
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

14
util.go
View File

@ -18,22 +18,12 @@ func GetProcessPIDs(name string) ([]int, error) {
for _, entry := range dir { for _, entry := range dir {
pid, err := strconv.Atoi(entry.Name()) pid, err := strconv.Atoi(entry.Name())
if entry.IsDir() && err == nil { if entry.IsDir() && err == nil {
f, err := os.ReadFile("/proc/" + entry.Name() + "/comm") f, err := os.ReadFile("/proc/" + entry.Name() + "/cmdline")
if err != nil { if err != nil {
return nil, err return nil, err
} }
if strings.Contains(string(f[:len(f)-1]), name) { if strings.Contains(string(f), name) {
pids = append(pids, pid)
continue
}
f, err = os.ReadFile("/proc/" + entry.Name() + "/cmdline")
if err != nil {
return nil, err
}
if strings.Contains(string(f[:len(f)-1]), name) {
pids = append(pids, pid) pids = append(pids, pid)
} }
} }