mirror of https://github.com/shirou/gopsutil
Merge pull request #228 from sean-/master
Correctly detect host Procs on all platforms.pull/231/head
commit
ca63fa830d
@ -1,3 +1,19 @@
|
||||
// +build linux
|
||||
|
||||
package common
|
||||
|
||||
import "os"
|
||||
|
||||
func NumProcs() (uint64, error) {
|
||||
f, err := os.Open(HostProc())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
list, err := f.Readdir(-1)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(len(list)), err
|
||||
}
|
||||
|
Loading…
Reference in New Issue