[util.go] It is better to leave just cmdline actually.
This commit is contained in:
parent
cf300b899a
commit
33cebee08f
14
util.go
14
util.go
@ -18,22 +18,12 @@ func GetProcessPIDs(name string) ([]int, error) {
|
||||
for _, entry := range dir {
|
||||
pid, err := strconv.Atoi(entry.Name())
|
||||
if entry.IsDir() && err == nil {
|
||||
f, err := os.ReadFile("/proc/" + entry.Name() + "/comm")
|
||||
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)
|
||||
continue
|
||||
}
|
||||
|
||||
f, err = os.ReadFile("/proc/" + entry.Name() + "/cmdline")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if strings.Contains(string(f[:len(f)-1]), name) {
|
||||
if strings.Contains(string(f), name) {
|
||||
pids = append(pids, pid)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user