#!/bin/sh # Copyright (C) 2003 Enrico Scholz # based on vserverkillall by Jacques Gelinas # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # This script kills all process it can finds # Only useful if you are using a security context. # It does nothing in context 0 USR_LIB_VSERVER=$(dirname $0) 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