#!/bin/sh -f
#killone: kills one process identified by parent process number
#         which is identified by a parent process identifier.
#         This is needed if more than one process of the same 
#         name may be running, and you only want to kill one of them.
#
# $1 = target process to be killed
# $2 = parent process identifier (e.g. 3param.in.#)
#
# 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
$PCMD | grep $2 | grep -v grep | grep -v killone | grep -v qcheck.ll > psfile.grep
read myname parentnum parentsparent < psfile.grep
echo "Parent process number = " $parentnum
#
# output final run time for $1 job
$PCMD | grep $1 | grep $parentnum > psfile.grep
read myname target junk1 junk2 duration < psfile.grep
echo "Final run time for $1 process identified by $2 is:"
echo $duration
#
# kill $1 process as identified by $parentnum
echo "kill -KILL" $target
kill -KILL $target
rm psfile.grep
