Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected defects in iotimeout script.
- Loading branch information
AutoBuild
committed
Feb 20, 2011
1 parent
cdeb30c
commit bb42747
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |