#!/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 USR_SBIN=/usr/sbin USR_LIB_VSERVER=/usr/lib/vserver CTX=`grep ^s_context /proc/self/status | sed s/s_context:// | (read a b; echo $a)` 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 # Kill the fakeinit process. It is shown as process one, but can't # be killed this way INITPID=`cat /proc/self/status | grep initpid: | (read a b; expr $b)` if [ "$INITPID" != "0" ] ; then echo kill init, pid $INITPID kill -9 $INITPID fi fi