shirou_gopsutil/internal/common/common_linux.go

20 lines
262 B
Go
Raw Normal View History

// +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
}
2016-07-12 02:07:55 +08:00
return uint64(len(list)), err
}