Skip to content

Instantly share code, notes, and snippets.

@rys
Last active December 15, 2015 14:28
Show Gist options
  • Save rys/5274314 to your computer and use it in GitHub Desktop.
Save rys/5274314 to your computer and use it in GitHub Desktop.
Updated CPU count detection for BSD-based OSes
diff --git a/scripts/functions/build_config b/scripts/functions/build_config
index a58ac98..44fb6a5 100755
--- a/scripts/functions/build_config
+++ b/scripts/functions/build_config
@@ -370,7 +370,21 @@ __rvm_detect_max_threads()
{
case "$(uname)" in
(Darwin|FreeBSD)
- sysctl -n hw.ncpu
+ if
+ __rvm_which sysctl >/dev/null
+ then
+ sysctl -n hw.ncpu
+ elif
+ [[ -x /usr/sbin/sysctl ]]
+ then
+ /usr/sbin/sysctl -n hw.ncpu
+ elif
+ [[ -x /sbin/sysctl ]]
+ then
+ /sbin/sysctl -n hw.ncpu
+ else
+ echo 1
+ fi
;;
(*)
cat /proc/cpuinfo 2>/dev/null | (grep vendor_id || echo 'one';) | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment