The current way we are check for running process may lead to wrong results. The 'ps | grep' command may return more than one line, which will cause a false result in the test comparison. Now we use 'pidof' to check if we have the process running.
Signed-off-by: Eduardo Valentin eduardo.valentin@ti.com --- thermal/thermal_03.sh | 4 ++-- thermal/thermal_06.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh index 4bb3982..9c20372 100755 --- a/thermal/thermal_03.sh +++ b/thermal/thermal_03.sh @@ -40,11 +40,11 @@ check_temperature_change() { local gpu_pid=0 local init_temp=$(cat $dirpath/temp) $CPU_HEAT_BIN & - cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + cpu_pid=$(pidof heat_cpu) check "start cpu heat binary" "test $cpu_pid -ne 0"
$GPU_HEAT_BIN & - gpu_pid=$(ps | grep $GPU_HEAT_BIN| awk '{print $1}') + gpu_pid=$(pidof $GPU_HEAT_BIN) check "start gpu heat binary" "test $gpu_pid -ne 0" sleep 5 local final_temp=$(cat $dirpath/temp) diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh index 0960cdb..ca1d033 100755 --- a/thermal/thermal_06.sh +++ b/thermal/thermal_06.sh @@ -48,11 +48,11 @@ check_trip_point_change() { local trip_type=0 local trip_type_path=0 $CPU_HEAT_BIN & - cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + cpu_pid=$(pidof heat_cpu) check "start cpu heat binary" "test $cpu_pid -ne 0"
$GPU_HEAT_BIN & - gpu_pid=$(ps | grep $GPU_HEAT_BIN| awk '{print $1}') + gpu_pid=$(pidof $GPU_HEAT_BIN) check "start gpu heat binary" "test $gpu_pid -ne 0"
local index=0