#!/bin/sh
# This script kills all process it can finds
# Only useful if you are using a security context.
# It does nothing in context 0
CTX=`cat /proc/self/status | grep s_context | sed s/s_context://`
CTX=`eval expr $CTX + 0`
if [ "$CTX" = 0 ] ; then
	echo Running in security context 0, do nothing
else
	cd /proc
	for SIG in -TERM -TERM -TERM -9
	do
		ONE=0
		for dir in *
		do
			case $dir in
			1)
				;;
			$$)
				;;
			[1-9]*)
				ONE=1
				echo kill $SIG "`/usr/lib/vserver/readlink /proc/$dir/exe`"[$dir]
				kill $SIG $dir
				;;
			*)
				;;
			esac
		done
		if [ "$ONE" = 0 ] ; then
			break
		fi
		sleep 1
	done
fi


