aboutsummaryrefslogtreecommitdiff
path: root/samples/killall
blob: 7030fe22bf29bd43e22e8bd283a3014bd16d1dd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/sh
# $Id: killall,v 1.3 2012/06/29 09:39:19 tom Exp $
# Linux has a program that does this correctly.

. ./setup-vars

for prog in $*
do
	pid=`ps -a |fgrep $prog |fgrep -v fgrep|sed -e 's/^[ ]*//' -e 's/ .*//' `
	if test -n "$pid" ; then
		echo killing pid=$pid, $prog
		kill -$SIG_HUP $pid || \
		kill -$SIG_TERM $pid || \
		kill -$SIG_KILL $pid
	fi
done