Merge pull request #1031 from scop/getconf

Get number of processors using getconf over cpuinfo grep
This commit is contained in:
Yamashita, Yuu 2017-11-09 17:39:32 +09:00 committed by GitHub
commit 428a94b3ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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