#!/bin/rc

# local command for master invoked by "run"

rfork ens

host=$1
if(! ~ $#* 1){
	echo usage: mrun host
	exit
}

# we are now on /usr/none
cd /usr
if(test -e pattern)
	cpu -h $host -P pattern -c /mnt/term/usr/none/srun
if not
	cpu -h $host -c /mnt/term/usr/none/srun

#sleep 1

# kill cpu by killing mrun
# don't kill cpu directly because cpu is widely used.
# note:
# 	kill mrun | rc
# is not effective.
# because mrun cannot be killed during cpu command is alive.
#
# make sure all tasks really finished
# because some of slaves can finish unexpectedly

# ppid is run's pid that is defined in run
cd /usr/none
echo mrun $host done
if(test -e done && test -e /proc/$ppid){
	echo killing run
	echo hangup>/proc/$ppid/notepg
}
