0ad/source/tools/utils.sh
Ralph Sennhauser 387ea927ac
Add util.sh shell library
A shell utilities function library starting with a first utility
function for getting the number of online CPUs.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-03-30 18:05:56 +02:00

13 lines
306 B
Bash
Executable file

#!/bin/sh
# Collection of sh utilities
# Return number of online cpu or 1 if it can't be determined.
utils_num_online_cpu()
{
getconf _NPROCESSORS_ONLN 2>/dev/null && return
getconf NPROCESSORS_ONLN 2>/dev/null && return
nproc 2>/dev/null && return
sysctl -m hw.nproc 2>/dev/null && return
echo 1
}