From 5b8b44bc3d603a2b71d4097354ff5103fac4e85b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Mar 2017 22:44:08 +0000 Subject: [PATCH] set timeout for wget and kill slow processes (e.g. in case controller is turned off) --- light.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/light.sh b/light.sh index c2cae7d..4ea80c7 100755 --- a/light.sh +++ b/light.sh @@ -98,7 +98,7 @@ case "$ROOM_NUMBER" in DR=$(sign $(($R_-$R))); DG=$(sign $(($G_-$G))); DB=$(sign $(($B_-$B))) R=$(($R+$DR)); G=$((G+$DG)); B=$(($B+$DB)) for i in 5:$R 4:$G 3:$B; do - wget -q -O- http://172.23.92.5/ecmd?channel%20$(echo $i | cut -d: -f1)%20$(echo $i | cut -d: -f2) > /dev/null 2>&1 & + wget -q --timeout 3 -O- http://172.23.92.5/ecmd?channel%20$(echo $i | cut -d: -f1)%20$(echo $i | cut -d: -f2) > /dev/null 2>&1 & COLOR_B_TMP="$(echo "$COLOR_B_TMP" | cut -c3-)" done sleep .1 @@ -109,7 +109,7 @@ case "$ROOM_NUMBER" in else COLOR_B_TMP=$COLOR_B for i in 5 4 3; do - wget -q -O- http://172.23.92.5/ecmd?channel%20$i%20$(printf "%d" "0x${COLOR_B_TMP:0:2}") > /dev/null 2>&1 & + wget -q --timeout 3 -O- http://172.23.92.5/ecmd?channel%20$i%20$(printf "%d" "0x${COLOR_B_TMP:0:2}") > /dev/null 2>&1 & COLOR_B_TMP="$(echo "$COLOR_B_TMP" | cut -c3-)" done fi