#!/bin/sh
#	Kill <pattern>
#	Kill -<sig> <pattern>...
#
if [ $# -lt 1 ];then echo Usage: $0 -signal pattern;exit 1;fi
if [ $# -lt 2 ];then S='-TERM'; else S="$1";shift;fi
for p
do	P=`ps gawwux \
		| grep "$p" \
		| sed -e "/ $$ /d" -e "/ grep /d" -e 's/  */	/g' \
		| cut -f2`
	if [ -n "$P" ];then
		echo Kill $S $P
		exec kill $S $P
	fi
done
exit 0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# This script runs 'ps gawux' and kills the processes that match the pattern. #
# Warning:  It is very easy to kill more than you intended to kill. Note that #
# on some Unix systems, the "kill" command doesn't accept symbolic names  for #
# signals;  if  yours is like this, then change the default '-TERM' to '-15'. #
# The -<sig> arg may only be omitted when  there's  just  a  single  pattern, #
# because if there are two or more args, the first is assumed to be a signal. #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# For Sys/V, you'll have to change "gawux" to "-elf" or some such.
