mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
getProcPids() minor improvement
reduce allocs a little bit.
This commit is contained in:
parent
83fad69316
commit
3bf429b9ca
1 changed files with 4 additions and 3 deletions
|
@ -84,18 +84,19 @@ func lookupPidDescriptors(fdPath string, pid int) []string {
|
|||
}
|
||||
|
||||
// getProcPids returns the list of running PIDs, /proc or /proc/<pid>/task/ .
|
||||
func getProcPids(pidsPath string) (pidList []int) {
|
||||
func getProcPids(pidsPath string) []int {
|
||||
f, err := os.Open(pidsPath)
|
||||
if err != nil {
|
||||
return pidList
|
||||
return []int{}
|
||||
}
|
||||
ls, err := f.Readdir(-1)
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return pidList
|
||||
return []int{}
|
||||
}
|
||||
ls = sortPidsByTime(ls)
|
||||
|
||||
pidList := make([]int, 0, len(ls))
|
||||
for _, f := range ls {
|
||||
if f.IsDir() == false {
|
||||
continue
|
||||
|
|
Loading…
Add table
Reference in a new issue