echo clitk3 directory: $vv_dir
cd ${vv_dir}/build
-nice -n 19 ionice -c3 make -j4 #is this good enough?
-#
-#function handle_exit
-#{
-# rm mem_use 2>>/dev/null
-# killall -s SIGCONT make
-# killall make
-# killall cc1plus
-# echo "Terminated, exiting..."
-# echo
-# echo
-# exit
-#}
-#
-#trap handle_exit SIGINT
-#available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*)
-#if [ -a "memory_exhausted_lock" ]
-#then
-# echo "Running in memory conservation mode..."
-# max_cpp_process_mem_use=1600000
-# cpus=$(( $available_mem / $max_cpp_process_mem_use ))
-# echo "Using $cpus cpu(s) should be safe..."
-# sleep 1
-# make -j${cpus}
-#else #use all the available computing power by default
-# cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 ))
-#fi
-#
-#nice -n12 ionice -c3 make -j ${cpus} $@ &
-#make_pid=$(jobs -p %nice)
-#
-##watch memory use to avoid crashes
+function handle_exit
+{
+ rm mem_use 2>>/dev/null
+ killall -s SIGCONT make
+ killall make
+ killall cc1plus
+ echo "Terminated, exiting..."
+ echo
+ echo
+ exit
+}
+
+trap handle_exit SIGINT
+available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*)
+if [ -a "memory_exhausted_lock" ]
+then
+ echo "Running in memory conservation mode..."
+ max_cpp_process_mem_use=1600000
+ cpus=$(( $available_mem / $max_cpp_process_mem_use ))
+ echo "Using $cpus cpu(s) should be safe..."
+ sleep 1
+ make -j${cpus}
+else #use all the available computing power by default
+ cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 2 ))
+ echo "Building with ${cpus} cpus..."
+fi
+
+nice -n12 ionice -c3 make -j ${cpus} $@ &
+make_pid=$(jobs -p %nice)
+
+#watch memory use to avoid crashes
#while ps $make_pid >>/dev/null
#do
# if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ]
# sleep 1
#done
#rm memory_exhausted_lock 2>>/dev/null
-#echo Done!
-#echo
+wait
+echo Done!
+echo