Skip to content

Commit

Permalink
Corrected defects in iotimeout script.
Browse files Browse the repository at this point in the history
  • Loading branch information
AutoBuild committed Feb 20, 2011
1 parent cdeb30c commit bb42747
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions iotimeout
@@ -1,28 +1,32 @@
# timelimit watches standard out for a delay longer than the timeout w/o any output.
# Example:
# make clean test | timeout 300
procid=$$
timelimit=$1
touch tmp.out # Set initial time in case never get any output
while true
do
(
while true
do
if [ ! -f tmp.out ]; then break; fi
lastline=$(date +%s -r tmp.out)
currtime=$(date +%s)
(( diff = currtime - lastline ))
if [ $diff -gt 10 ]
then
echo "Over $diff seconds w/o response."
echo "More than $diff seconds w/o any response."
fi
if [ $diff -gt $timelimit ]
then
echo "Exceeded maximim timout of ${timelimit} seconds w/o response."
kill -9 0
exit 1
fi
sleep 10
done &
done
) &
while read -r line
do
echo "$line"
touch tmp.out
done
rm tmp.out
wait
echo "iotimeout finished."

0 comments on commit bb42747

Please sign in to comment.