diff --git a/daemon/procmon/find.go b/daemon/procmon/find.go index c42d8c7a..65a0f6ff 100644 --- a/daemon/procmon/find.go +++ b/daemon/procmon/find.go @@ -84,18 +84,19 @@ func lookupPidDescriptors(fdPath string, pid int) []string { } // getProcPids returns the list of running PIDs, /proc or /proc//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