#!/bin/sh -f
#killorphan: kills all processes with $1 name and whose parent process is 1
#            Used for killing runaway orphan processes (e.g. qcheck)
#
# $1 = target process to be killed
#
# checked out for IBM 
# MSE, 1/31/96
#
# on suns use "ps -x"
# on hps, sun solaris, and IBM use "ps -ef"
PCMD="ps -ef"
#
# get parent process number
#
# kill any $1 orphan processes as identified by "     1   " 
# in parent process field
$PCMD | grep $1 | grep "     1   " | \
while read myname target junk
do
  echo "kill -KILL" $target
  kill -KILL $target
done
