xref: /freebsd/contrib/dialog/samples/killall (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#! /bin/sh
2*a96ef450SBaptiste Daroussin# $Id: killall,v 1.4 2019/12/10 23:48:58 tom Exp $
34c8945a0SNathan Whitehorn# Linux has a program that does this correctly.
42a3e3873SBaptiste Daroussin
52a3e3873SBaptiste Daroussin. ./setup-vars
62a3e3873SBaptiste Daroussin
7*a96ef450SBaptiste Daroussinfor prog in "$@"
84c8945a0SNathan Whitehorndo
9*a96ef450SBaptiste Daroussin	pid=`ps -a |fgrep "$prog" |fgrep -v fgrep|sed -e 's/^[ ]*//' -e 's/ .*//' `
104c8945a0SNathan Whitehorn	if test -n "$pid" ; then
11*a96ef450SBaptiste Daroussin		echo "killing pid=$pid, $prog"
12*a96ef450SBaptiste Daroussin		kill "-$SIG_HUP" "$pid" || \
13*a96ef450SBaptiste Daroussin		kill "-$SIG_TERM" "$pid" || \
14*a96ef450SBaptiste Daroussin		kill "-$SIG_KILL" "$pid"
154c8945a0SNathan Whitehorn	fi
164c8945a0SNathan Whitehorndone
17