All pastes #634886 Raw Edit

Anonymous

public text v1 · immutable
#634886 ·published 2007-07-26 18:45 UTC
rendered paste body
check()
{
	pidrun="$1"
	location="$2"

	minspace=200000
	diskspace=999999
	while [ "$diskspace" -gt "$minspace" ]
	do
		diskspace=$(df --portability  $location | awk 'END {print $4}')
		echo "check: $$"
		echo "check: pidrun: $pidrun"
		sleep 2
	done

	kill -15 $pidrun
}

run()
{
	location="$1"
	
	echo "run: $$"
	cp -r "/media/sda3/linux-2.6.22.1" "$location/testdir"
	
	# other command 
	# othercommand
	# other command
	
	exit	
}

echo $PWD
echo $$
location="/home/$USER"

run $location &
pidrun=$!

check $pidrun $location &
pidcheck=$!

wait $pidrun

kill -15 $pidrun
kill -15 $pidcheck

exit

question:
How do i automaticly get all commands executed in subshell "run" killed, when this subshell "run" is killed?