returning 0 and error if SysctlUint32 raises an error

This commit is contained in:
Minje Park 2019-03-21 23:52:34 +09:00
parent ca1fcad2aa
commit caebe5dbe4
1 changed files with 1 additions and 3 deletions

View File

@ -4,7 +4,6 @@ package cpu
import (
"context"
"runtime"
"strconv"
"strings"
@ -96,9 +95,8 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) {
}
count, err := unix.SysctlUint32(cpuArgument)
if err != nil {
return runtime.NumCPU(), nil
return 0, err
}
return int(count), nil