timeout 10 script
ret=$?
if [ "${ret}" -eq 124 ]; then
  exit 1
else
  trap cleanup TERM
  # no hang
fi
