[interprocess] Mutex Query
I want to make sure that when my program exits ungracefully (CTRL-C, seg fault, etc) it releases a Boost.Interprocess named_upgradable_mutex, if it's holding it. I've created a signal handler to catch these ungraceful exits. Is there any way to tell if my process currently holds an exclusive or sharable lock on the mutex? I've tried blindly calling mutex.unlock() and mutex.unlock_sharable() but that seems to permanently lock the mutex when the shareable lock is set. RickW
Rick Way wrote:
I want to make sure that when my program exits ungracefully (CTRL-C, seg fault, etc) it releases a Boost.Interprocess named_upgradable_mutex, if it's holding it. I've created a signal handler to catch these ungraceful exits. Is there any way to tell if my process currently holds an exclusive or sharable lock on the mutex?
I've tried blindly calling mutex.unlock() and mutex.unlock_sharable() but that seems to permanently lock the mutex when the shareable lock is set.
Sorry, there is no way to do this. You'll need to mark this type of information externally in the structure where the mutex resides. Ion
participants (2)
-
Ion Gaztañaga
-
Rick Way