2015-09-16 15:19:33 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package common
|
2016-07-12 02:05:30 +08:00
|
|
|
|
|
|
|
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)), error
|
|
|
|
}
|