wait_until_done () { pid=$1 cnt=${DRILLBIT_TIMEOUT:-300} origcnt=$cnt while kill -0 $pid > /dev/null 2>&1; do if [ $cnt -gt 1 ]; then cnt=`expr $cnt - 1` sleep 1 else echo "Process did not complete after $origcnt seconds, killing." kill -9 $pid exit 1 fi done return 0 }