I am working on a program that uses shared memory. Several instances of the specified program will either connect to the existing one, or create it again, and return it to the OS when there are no other processes, or simply disconnect it and complete it. I thought of using a simple counter to keep track of how many processes are using it.
I use the atexit() function to clear, but afaik, when I receive a SIGKILL signal, the processes will not clear, so if any of these processes does not finish normally, I may never be able to clear the memory.
Is there a way to indicate what to do even after a SIGKILL signal? I'm probably going to write some kind of timer-like mechanism to check if all processes are still alive, but I really would like to avoid this if there is another way.
c linux signals
felace
source share