Similar to: Delete all shared memory and semaphores on Linux however, I want to do so in C, not with some script.
My specific problem: in linux + mac, when I debug a program and terminate it mid process, the shared resources (memory + semaphores) arent released. My program does some client server stuff where the server is the first process to acquire the shared resources. Therefore, after a termination without detaching, when I restart the program, it assumes that it is the client when there is no server (because the resource has been created and not released).
Currently, I am using Qt to manage the shared resources but Qt does not appear to have a way to deal with this situation (the error code that create returns is that the resource has already been created). Therefore, Im looking to a more OS specific way to do this. NOTE: windows does not have this problem because the shared resource is released on termination automatically.