Omaha #3371 all subprocesses now killed when cave.sh is killed

Change-Id: Ibceb3f8c8902b9df94b16fac83db69b0c4dcccc2

Former-commit-id: d6e181d301 [formerly 0973e5ac41] [formerly 7e70fbda27] [formerly d6e181d301 [formerly 0973e5ac41] [formerly 7e70fbda27] [formerly ae5fa893a9 [formerly 7e70fbda27 [formerly e4becce5325aad266fd93548d27e5e122b145011]]]]
Former-commit-id: ae5fa893a9
Former-commit-id: 97fc979b3b [formerly a1bce34fda] [formerly ef9dbe97b4271805e63ea28026e72a445813455e [formerly e72c34d361]]
Former-commit-id: dd87970cd72b7fb271a99e965d270def8120be94 [formerly 272c0a2e2d]
Former-commit-id: d8ce5db467
This commit is contained in:
Brian Clements 2014-07-11 08:54:08 -05:00
parent 7705c8b16d
commit f505d1221b

View file

@ -35,6 +35,7 @@
# Jun 20, 2014 #3245 bclement forEachRunningCave now accounts for child processes # Jun 20, 2014 #3245 bclement forEachRunningCave now accounts for child processes
# Jul 02, 2014 #3245 bclement account for memory override in vm arguments # Jul 02, 2014 #3245 bclement account for memory override in vm arguments
# Jul 10, 2014 #3363 bclement fixed precedence order for ini file lookup # Jul 10, 2014 #3363 bclement fixed precedence order for ini file lookup
# Jul 11, 2014 #3371 bclement added killSpawn()
source /awips2/cave/iniLookup.sh source /awips2/cave/iniLookup.sh
@ -312,13 +313,23 @@ function deleteOldCaveDiskCaches()
cd $curDir cd $curDir
} }
# takes in a process id
# kills spawned subprocesses of pid
# and then kills the process itself
function killSpawn()
{
pid=$1
pkill -P $pid
kill $pid
}
# log the exit status and time to a log file, requires 2 args pid and log file # log the exit status and time to a log file, requires 2 args pid and log file
function logExitStatus() function logExitStatus()
{ {
pid=$1 pid=$1
logFile=$2 logFile=$2
trap 'kill $pid' SIGHUP SIGINT SIGQUIT SIGTERM trap 'killSpawn $pid' SIGHUP SIGINT SIGQUIT SIGTERM
wait $pid wait $pid
exitCode=$? exitCode=$?
curTime=`date --rfc-3339=seconds` curTime=`date --rfc-3339=seconds`