#!/bin/sh

# This script attempts to kill any processes in
# the auv/onboard/bin/debug (modify-able to bin/optimized)
# and also cleans out shared memory & semaphores.

echo "Killing all tasks (even on node 2, if it's up)..."

# So we use the list of executables in the directory
# as an argument to slay.

if test -f $AUV_BIN_DIR
then
cd $AUV_BIN_DIR
else
cd $AUV/bin/debug
fi

slay -f -9 -n 1 *
rm -f //1/dev/shmem/*
rm -f //1/dev/mqueue/*

NumNodes=`alive -u | wc -l`
if [ "$NumNodes" -gt "1" ]
then
	slay -f -9 -n 2 *
	rm -f //2/dev/shmem/*
	rm -f //2/dev/mqueue/*
fi

echo "Everything should be killed, and /dev/shmem & /dev/mqueue are cleaned out, too."
