-
Notifications
You must be signed in to change notification settings - Fork 102
Some problem of ListPID #33
Copy link
Copy link
Open
Description
Hello, I found that the 'ListPID()' function will show all of processes include sub-threads. And this may not suit for someone. I found source code in 'top' command, it only read dir in /proc which is digit & isDir, this will not list the pid which is not main thread. I give my simple code under below:
func ListProgram(path string) ([]uint64, error) {
pids := make([]uint64, 0, 20)
infos, err := ioutil.ReadDir(path)
if err != nil {
return nil, err
}
for _, info := range(infos) {
pid, err := strconv.ParseUint(info.Name(), 10, 64)
if err != nil {
continue
}
pids = append(pids, pid)
}
return pids, nil
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels