kill_processing (version 0.0)
You can also look at:
#! /usr/bin/perl
##############################################################################
#
# SYNTAX: kill_processing
#
# DESCRIPTION: This utility finds all parent, grandparent, etc. processes
# DESCRIPTION: and then it kills all of them.
#
# VERSION: 0.0
#
# HISTORY:
#
##############################################################################
$SUBS=$ENV{"SUBS"};
$PROCTOP=${SUBS};
$PROCTOP =~ s/(.*)\/.*/$1/;
print "kill processing\n";
#########################
# Read the process table
#########################
open PROCESS, "ps -afe |";
while (<PROCESS>) {
($uid,$pid,$ppid,$c,$stime,$tty,$time,$cmd, $cmd2, $cmd3)=split;
if ( $uid ne "root" ) {
$parent{$pid}=$ppid;
$command{$pid}="$cmd $cmd2 $cmd3";
}
}
close PROCESS;
###################################################
# Collect sucessive process parents until we reach
# the stream daemon or a shell.
###################################################
$list="";
$pid=$$;
while ($command{$pid} =~ /$PROCTOP/) {
$list="$pid $list";
$pid=$parent{$pid};
}
#################
# Kill them all!
#################
system("kill $list");