returning 0 and error if SysctlUint32 raises an error
This commit is contained in:
parent
ca1fcad2aa
commit
caebe5dbe4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue