Author: St John Karp <firstname.lastname@example.org>
Date: Mon, 15 Aug 2022 22:10:59 -0400
Replace call to nproc with grepping /proc/cpuinfo
This change only affects the Linux logic for determining the number
of processors. nproc is not a universal tool but /proc/cpuinfo is
nearly always populated. The BSD fallbacks are unchanged.
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/squeeze.sh b/squeeze.sh
@@ -29,9 +29,13 @@ proc_ids=""
# Max number of processes to run at once.
# There is no way to do `nproc` with only POSIX tools,
# so the best way to make this portable is with fallbacks.
-max_processes="$(nproc 2>/dev/null ||
+# `nproc` itself isn't even universal on Linux, so the safest
+# place to get the number of processors on Linux is /proc/cpuinfo.
+ grep -c ^processor /proc/cpuinfo ||
sysctl -n hw.ncpu 2>/dev/null ||
- getconf _NPROCESSORS_ONLN 2>/dev/null)"
+ getconf _NPROCESSORS_ONLN 2>/dev/null
# Regenerate everything if the force flag has been used or there is
# no RSS file, but otherwise only regenerate Markdown files that have