Leave no processes or files behind on exit, allow updatenode to happily exit

Actually retry every interval rather than just endlessly listening

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16635 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2013-06-14 14:39:12 +00:00
parent 25c5f5fc28
commit 246362ca48

View File

@ -13,12 +13,19 @@ touch /tmp/killme.$parpid
exec 2> /dev/null
while ! grep 'resourcerequest: ok' /tmp/goahead.$parpid > /dev/null; do
(
echo "resourcerequest: xcatd" >&13
exec 14<>/proc/self/stat
read mystat<&14
mypid=$(echo $mystat|cut -d " " -f 4)
(sleep $(((RANDOM%60)+120)).$((RANDOM%50)); if [ -f /tmp/killme.$parpid ]; then kill -TERM $mypid; fi) &
echo $! > /tmp/sleeperpid.$parpid
exec awk '{print $0 > "/tmp/goahead.'$parpid'";exit}' <&13
)
done
sleeper=$(cat /tmp/sleeperpid.$parpid)
sleeper=$(ps -ef|awk "\$3==$sleeper"|awk '{print $2}')
kill -TERM $sleeper
rm /tmp/goahead.$parpid
rm /tmp/sleeperpid.$parpid
rm /tmp/killme.$parpid