Get number of processors using getconf over cpuinfo grep

This commit is contained in:
Ville Skyttä 2017-11-08 19:07:20 +02:00
parent 7ab48c47fd
commit fc4f496545

View file

@ -155,7 +155,8 @@ num_cpu_cores() {
num="$(sysctl -n hw.ncpu 2>/dev/null || true)" 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}" num="${num#0}"
;; ;;
esac esac