diff --git a/sysconf_linux.go b/sysconf_linux.go index cd9845f..93e13d3 100644 --- a/sysconf_linux.go +++ b/sysconf_linux.go @@ -86,10 +86,16 @@ func getNprocsProcStat() (int64, error) { s := bufio.NewScanner(f) for s.Scan() { if line := strings.TrimSpace(s.Text()); strings.HasPrefix(line, "cpu") { - l := strings.SplitN(line, " ", 2) - _, err := strconv.ParseInt(l[0][3:], 10, 64) - if err == nil { - count++ + cpu, _, found := strings.Cut(line, " ") + if found { + // skip first line with accumulated values + if cpu == "cpu" { + continue + } + _, err := strconv.ParseInt(cpu[len("cpu"):], 10, 64) + if err == nil { + count++ + } } } else { // The current format of /proc/stat has all the