mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-11-22 20:01:26 +01:00
num_cpu_cores: Prefer getconf over cpuinfo grep, simplify grep usage
This commit is contained in:
parent
eabe1f36a5
commit
67c47603ee
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue