#!/usr/bin/perl -w
# Author: zixia@yahoo.com
# 2000-7-16
$user = $ARGV[0] or die "Usage:\n\tkilluser userid filter\n";
$filter = $ARGV[1];
open( FD, "ps -u $user|" ) or die "open";
while( $line=<FD> ){
chop $line;
if( $line=~m!^\s*(\d+)! ){
$pid = $1;
if( !defined $filter || $line=~m!$filter! ){
print $line, "\n";
push( @pids, $pid );
}
}
}
close( FD );
kill 15, @pids;
sleep 1;
kill 9, @pids;