#!/bin/ksh
#
# Script to cleanup shared memory segments that might get left around
# if the VEE process/tick subprocess got a "kill -9" done to them.
# Not cleaning up the shared memory segment that VEE uses to talk to
# the tick program will eventually cause VEE to stop running because
# the system cannot allocate any more shared memory segments for either
# 1) the user limit was exceeded or 2) the system limit was exceeded.
#


segs=$(ipcs -m | grep $(whoami) | cut -c2-8)

for seg in $segs; do
	echo "ipcrm -m $seg"
	ipcrm -m $seg
done

segs=$(ipcs -m | grep $(whoami) | cut -c2-8)
if [ ! -z "$segs" ]; then
	echo "Segments left:"
	echo "$segs"
fi
