Subject: Re: killall(1)
To: Andy Doran <ad@netbsd.org>
From: Julian Assange <proff@q.org>
List: tech-userlevel
Date: 10/08/1999 10:02:46
Andy Doran <ad@netbsd.org> writes:

> I have a killall(1) command here (to NetBSD 'spec', written in C, doesn't
> use procfs) that signals processes not only by name but tty too. Given the
> usefulness and small size of the thing, would it be reasonable to include
> it in the base system?
> 
> - ad

Here's mine:

#!/bin/sh
flags="-TERM"
case $1 in -*) flags="$1"; shift;; esac
patterns="evilfuckinghack"
for n in $*
do
  patterns="$patterns|$n"
done
killed="`ps ax|awk '$5 ~ /'$patterns'/ {print $1}'`"
test -z "$killed" && exit 1
echo $killed
kill $flags $killed
exit $?

And you're right. It *is* incredibly useful.