General
cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a HUP signal to process doesnt work on HP-IA

girishgawali
Occasional Advisor

Sending a HUP signal to process doesnt work on HP-IA

I got the failure in the scripts on HP-IA while running the "reorgdb" process when we send a HUP signal to it.

below is the scripts for your information

#!/bin/sh
# sig_reorgdb.sh
set -x
. sig_Scripts.sh

#reorgdb is the database utility process
dbUtil=reorgdb
dbName=$1
signal1="INT QUIT TERM HUP USR1 USR2"
sigTstp=TSTP


# Calculation of Runtime : Reorgdb
expected_time=`get_expected_seconds reorgdb $dbName`
sleepTime=`expr $expected_time / 2`


for sig1 in $signal1
do
# We break out from the following retry loop as soon as we get
# a valid test result.

got_valid_test_run=0
until [ $got_valid_test_run -eq 1 ]
do
restore $dbName
# use very low max_page_buffs to make reorgdb run longer
chk stopdb $dbName
setup_db -update -add_be max_page_buffs 10 -db $dbName
if [ $sig1 = "INT" -o $sig1 = "QUIT" ]; then
genSignal $sig1 $sleepTime $dbUtil ${dbName}${AT}
else
genSuspSig $sig1 $sigTstp $sleepTime $dbUtil ${dbName}${AT}
fi
# If the setdbid process finished before genSignal() had a chance
# to send signal then we need to start this testcase from the top
if test -f process_finished_too_fast
then
# Also since sleep time was apparently too long
# let's reduce it.
if [ "$sleepTime" -gt 1 ]
then
sleepTime=`expr $sleepTime - 1`
fi
rm process_finished_too_fast
continue
fi

# wait for reorgdb to finish (if it's still running)
wait $pid
echo $?
...........................................
#!/bin/sh
#sig_Scripts.sh

get_expected_seconds()
{
rm -f _secs.tmp
if [ `uname` = "Linux" ]
then
/usr/bin/time -p $* > _secs.tmp 2>&1
else
/usr/bin/time $* > _secs.tmp 2>&1
fi
if [ `uname` = "AIX" ]
then
awk '/Real/ {print $2}' _secs.tmp | awk -F. '{print $1}'
else
awk '/real/ {print $2}' _secs.tmp | awk -F. '{print $1}'
fi
}


# Usage : Signal SigType sleepTime commandToBeExectuted
genSignal()
{
if [ `uname` = "Linux" ]
then
KILL=/bin/kill
else
KILL=/usr/bin/kill
fi
sigType1=$1
shift
sleepTime=$1
shift
$* &
pid=$!
if [ $sleepTime -eq 0 ]; then
sig_msleep.exe 60
else
sleep $sleepTime
fi

if $KILL -${sigType1} $pid
then
return 0
else
echo "Test Error: kill failed -- Target process may have finished before kill was run "
touch process_finished_too_fast
return 1
fi
}

genSuspSig()
{
sigType2=$1
shift
genSignal $*
if $KILL -${sigType2} $pid
then
return 0
else
echo "Test Error: kill failed -- Target process may have finished before kill was run "
touch process_finished_too_fast
return 1
fi
}
...........................................
when i removed HUP from signal1="INT QUIT TERM HUP USR1 USR2" this scripts work fine.

So the question is when we send a HUP signal
why this script fails?

Does HUP signal behave differently on HP-IA?

Below is the log of the scripts:
..
..
..
..
+ [ HUP = INT -o HUP = QUIT ]
+ genSuspSig HUP TSTP 0 reorgdb tdbrD0gxPDB1util_sig_reorgdb
+ test -f process_finished_too_fast
+ wait 20292

after this its not going ahead as reorgdb process got the signal HUP


7 REPLIES
Dennis Handly
Acclaimed Contributor

Re: Sending a HUP signal to process doesnt work on HP-IA

>after this it's not going ahead as reorgdb process got the signal HUP

It seems if it is stuck on wait, it's because the signal was handled and the process wasn't killed.
girishgawali
Occasional Advisor

Re: Sending a HUP signal to process doesnt work on HP-IA

Thanks for reply....

It seems if it is stuck on wait, it's because the signal was handled and the process wasn't killed.

yes,it it stuck on wait but only in case of HP-IA.On other platform scripts going ahead.
Also after running the script if I grep for that process id ,process was not running.
It means process was killed

Dennis Handly
Acclaimed Contributor

Re: Sending a HUP signal to process doesnt work on HP-IA

>it is stuck on wait but only in case of HP-IA. On other platform scripts going ahead.

What other platforms? Any HP-UX ones on at least 11.23?

>if I grep for that process id, process was not running. It means process was killed

Yes. It shouldn't wait for that.
Can you add a "ps -fp $pid" before that wait?
girishgawali
Occasional Advisor

Re: Sending a HUP signal to process doesnt work on HP-IA

>What other platforms? Any HP-UX ones on at least 11.23?

other platforms are AIX,Solaris,Linux

>Can you add a "ps -fp $pid" before that wait?

Can you please tell me the reason for adding
"ps -fp $pid" before wait
Dennis Handly
Acclaimed Contributor

Re: Sending a HUP signal to process doesnt work on HP-IA

>other platforms are AIX, Solaris, Linux

(So they aren't HP-UX and your HP-IA is a typo.)

>Can you please tell me the reason for adding
"ps -fp $pid" before wait

To prove whether that process didn't exist when it did the wait. We are still debugging, this isn't a fix.
girishgawali
Occasional Advisor

Re: Sending a HUP signal to process doesnt work on HP-IA

>To prove whether that process didn't exist when it did the wait. We are still debugging, this isn't a fix.

Below is the log of the scripts having
"ps -fp $pid" before wait
..
..
..

+ [ HUP = INT -o HUP = QUIT ]
+ genSuspSig HUP TSTP 0 reorgdb tdblwlrGPDB1util_sig_reorgdb
+ test -f process_finished_too_fast
+ ps -fp 5870
UID PID PPID C STIME TTY TIME COMMAND
+ wait 5870
+ echo 129
129
+ chkReorgdb

stopdb -f tdblwlrGPDB1util_sig_reorgdb
VERSANT Utility STOPDB Version 8.0.0.0
Copyright (c) 1988-2009 VERSANT Corporation
..
..
..

After adding "ps -fp $pid ", scripts is not getting stuck in wait and works fine.
Also if you see the log o/p of ps -fp $pid shows that process(reorgdb) didnt exist.
Though "ps -fp $pid" is not a fix ,scripts works. Strange


Dennis Handly
Acclaimed Contributor

Re: Sending a HUP signal to process doesnt work on HP-IA

>Though "ps -fp $pid" is not a fix, scripts works. Strange

Yes, strange. Perhaps it just takes time for the process to die, longer than the time from kill to the wait?

In any case, if you know you killed it, why bother with the wait?