Commit 9d710886 authored by Oskar Skog's avatar Oskar Skog

Pre 0.5.3: mkenginecfg: Work around for OpenBSD bug

parent 537bbf14
......@@ -66,14 +66,17 @@ __EOF__
# Count the number of logical processors.
# WARNING: If the first command in a pipeline fails, the pipeline itself may
# 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 kern.smp.cpus; } # BSD (Should I use this?)
_n3 () { sysctl -n hw.logicalcpu; } # BSD
_n4 () { sysctl -n hw.ncpu; } # BSD (fallback)
_n5 () { psrinfo && psrinfo | wc -l; } # (OpenSolaris)/openidiana
n=0; last=5
_n2 () { sysctl -n hw.ncpufound; } # OpenBSD, BUG *1
_n3 () { sysctl -n kern.smp.cpus; } # BSD (Should I use this?)
_n4 () { sysctl -n hw.logicalcpu; } # BSD
_n5 () { sysctl -n hw.ncpu; } # BSD (fallback)
_n6 () { psrinfo && psrinfo | wc -l; } # (OpenSolaris)/openidiana
n=0; last=6
while [ $n -le $last ]; do
ncpus=`_n$n` 2> /dev/null && break
n=$(($n + 1))
......
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