#!/bin/sh
#-*- tab-width: 4; -*-
# ex:ts=4

doing()
{
	local __finish=false

	echo -n "$1"
	trap "__finish=true" 6
	while true; do
		if ${__finish}; then
			echo -n 'done'
			sleep 1
			break
		else
			echo -n '.'
			sleep 1
		fi
	done
	tput dl
	sleep 1
}

running()
{
	case $1 in
	start)
		shift
		doing "$1" &
		_doing_proc_id=$!
		;;
	stop)
		kill -6 ${_doing_proc_id}
		sleep 1
		;;
	esac
}

echo $$ > /var/run/test.pid
trap "running stop; kill -9 $$" 2
trap "exec >> /var/log/test.log 2>&1" 30
running start "Exec process"
exec >> /var/log/test.log 2>&1
cd /usr/src
make buildworld
running stop
