#!/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 # THis script assumes it is already in the proc directory of the vserver USR_SBIN=/usr/sbin USR_LIB_VSERVER=/usr/lib/vserver CTX=`grep ^XID /proc/self/vinfo | sed s/XID:// | (read a b; echo $a)` CTX=`eval expr $CTX + 0` if [ "$CTX" = 0 ] ; then echo Running in security context 0, do nothing elif [ ! -d "1" ] ; then echo "Sub-directory 1 (one) does not exist, we are not in /proc" >&2 exit 1 else for SIG in -TERM -TERM -TERM -9 do ONE=0 for dir in * do case $dir in 1) ;; $$) ;; [1-9]*) ROOT="`$USR_LIB_VSERVER/readlink $dir/root 2>/dev/null`" if [ "$ROOT" != "/" -a "$ROOT" != "" ] ; then ONE=1 echo kill $SIG "`$USR_LIB_VSERVER/readlink $dir/exe 2>/dev/null`"[$dir] kill $SIG $dir fi ;; *) ;; esac done if [ "$ONE" = 0 ] ; then break fi sleep 1 done fi