Commit 5c1d9c4e authored by Oskar Skog's avatar Oskar Skog

nproc and lscpu

parent 640205aa
......@@ -69,14 +69,14 @@ __EOF__
# succeed! (wc -l says there are zero processors.)
# BUG *1: sysctl(1) on OpenBSD does not fail, the first sysctl command
# must work.
# NOTICE v: Don't forget the semicolon!
_n0 () { nproc --all; } # Debian
_n1 () { lscpu && lscpu -p | grep -v '#' | wc -l; } # (Linux)/Debian
_n2 () { sysctl -n hw.ncpufound; } # OpenBSD (BUG *1)
_n3 () { sysctl -n kern.smp.cpus; } # FreeBSD
_n4 () { sysctl -n hw.logicalcpu; } # Mac OS X
_n5 () { sysctl -n hw.ncpu; } # OpenBSD, NetBSD, DragonflyBSD, Mac OS X
_n6 () { psrinfo && psrinfo | wc -l; } # (OpenSolaris)/openidiana
# NOTICE v: Don't forget the semicolon!
_n0 () { nproc; } # GNU coreutils
_n1 () { lscpu && lscpu -p | grep -v '#' | wc -l;} # util-linux
_n2 () { sysctl -n hw.ncpufound; } # OpenBSD (BUG *1)
_n3 () { sysctl -n kern.smp.cpus; } # FreeBSD
_n4 () { sysctl -n hw.logicalcpu; } # Mac OS X
_n5 () { sysctl -n hw.ncpu; } # OpenBSD, NetBSD, DragonflyBSD, Mac OS X
_n6 () { psrinfo && psrinfo | wc -l;} # (OpenSolaris)/openidiana
n=0; last=6
while [ $n -le $last ]; do
ncpus=`_n$n` 2>/dev/null && break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment