Discussion Locked

Program gets semaphore but won't let go.

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have HP-UX with Oracle DB. I'm running a C program that first locks on a semaphore, then runs, then it should release the semaphore. This program is set to run every 30 minutes. Sometimes when it tries to run the semaphore is still locked from theprevious run. I know I can use a Unix command to release the semaphore, but is there a way to improve the Unix system to accept the release semaphore command that's in the program? I can't alter the program, and it does work with other customers. Therefore it has to be something it may OS that is keeping the semaphore from releasing.

5 replies

by buckle

Semaphores are a pain. If it has not been reset it could be because to previous call to the programme has not finished. If it has finished try writing a perl script to clear the semaphore and then call your programme. Have your perl script run every 30 minutes instead of the programme itself.

by jay allen

Welcome to HP-UX, i have this problem too with other programs such as mqseries. The best way to really kill it is to run a script using th ipcs command to search and clear out the memory. Here is our example:
echo ' '
echo ' '
echo '#########################################################'
echo '### ###'
echo '### WARNING .... YOU ARE ABOUT TO REMOVE ###'
echo '### .... ALL MQM RESOURCES. ###'
echo '#########################################################'
echo ' '
echo 'Do you wish to continue (no / yes) ? '
read ANSWER
if [ $ANSWER = 'yes' ]
then
echo ' '
echo 'Please Wait ..... Removing all MQM IPC resources ..... '
exec ipcrm `ipcs |grep ' mqm' |sed 's/^/-/;s/^-s/-s /;s/^-m/-m /;s/ */ /' |cut -f1-2 -d ' '`
fi

I hope this helps....Good Luck...

This discussion is closed to new replies.