Semaphore Usage Problem

[email protected]
Newsgroups gmane.comp.mozilla.devel.nspr
Organization http://groups.google.com
Message-ID <347a83c4-46d1-453c-a100-54e5a3572b39@s19g2000prg.googlegroups.com>
I am using PRSem for managing various resources in my application.

As these semaphores has kernel persistence, I run into a problem now
and then.

If my program terminates abruptly, the next time I start the program,
it may wait forever on one of the semaphores
created by previous execution which had been terminated abruptly.

My question is how can I recover from this without restarting the
system. Is there any strategy to use semaphores?

One answer can be: Dont terminate program abruptly.
But I have to sometime. If I am debugging or doing something, I do
terminate.
More over, If my program crashes due to some coding error, the user
may not want to restart the whole system.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.