I have a c program that uses sem_open() to create a semaphore and releases it before it exits. But when my program crashes in the middle, the semaphore is hanging there since the program didn't get to the point where it releases the semaphore.
Can someone please tell me how I can handle this? How do I release the semaphore(or other type of resources) when programs abnormally stops?
Thanks in advance.