shirou_gopsutil/internal/common/common_linux.go

20 lines
264 B
Go

// +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)), error
}