Merge pull request #77 from mmichal10/limit-configure-subprocesses-number

configure: Prevent spawning more subprocesses than CPUs available.
This commit is contained in:
Michał Wysoczański 2019-08-02 12:25:46 +02:00 committed by GitHub
commit 5603a77302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
configure vendored
View File

@ -24,19 +24,21 @@ CONFIG_FILE=$SCRIPTPATH/"config.out"
generate_config() {
rm -f ${CONFIG_FILE}
touch ${CONFIG_FILE}
declare -a pid_list
progress=0
n_cores=$(nproc)
# Compile each test module in background
echo "Preparing configuration"
for file in $CONFIG_FILES; do
progress=$((progress+1))
# $1 - Action to be performed
# $2 - File with stored configuration
# $3 - Name of called script (since script is running as subprocess
# it has to be passed explicitly)
source $file "check" "$CONFIG_FILE" "$file" &
pid_list+=($!)
# Prevent spawning more subprocesses than CPU available
while [ $(ps --no-headers -o pid --ppid=$$ | wc -w) -ge $n_cores ] ; do
sleep 1
done
done
# Wait for all compilation processes to finish