Unverified Commit 449ba6b3 authored by SHIBATA Hiroshi's avatar SHIBATA Hiroshi Committed by GitHub
Browse files

Merge pull request #1150 from scop/ncpus

num_cpu_cores: Prefer getconf over cpuinfo grep, simplify grep usage
parents eabe1f36 67c47603
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -154,7 +154,8 @@ num_cpu_cores() {
    num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
    ;;
  * )
    num="$(grep ^processor /proc/cpuinfo 2>/dev/null | wc -l | xargs)"
    num="$({ getconf _NPROCESSORS_ONLN ||
             grep -c ^processor /proc/cpuinfo; } 2>/dev/null)"
    num="${num#0}"
    ;;
  esac