]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/dialog/samples/killall
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / dialog / samples / killall
1 #! /bin/sh
2 # $Id: killall,v 1.2 2004/09/17 19:56:18 tom Exp $
3 # Linux has a program that does this correctly.
4 for prog in $*
5 do
6         pid=`ps -a |fgrep $prog |fgrep -v fgrep|sed -e 's/^[ ]*//' -e 's/ .*//' `
7         if test -n "$pid" ; then
8                 echo killing pid=$pid, $prog
9                 kill -1 $pid || \
10                 kill -15 $pid || \
11                 kill -9 $pid
12         fi
13 done