[Interest] Problem with QSharedMemory

Guido Seifert Wargand at gmx.de
Sat Jan 26 11:38:58 CET 2013

I have a minor problem with QSharedMemory. I do the necessary lock/unlock and attach/detach. Process 1 creates a shared memory segment, writes into it. Process 2 attaches, reads, and detaches. Process 1 detaches. This should destroy the shared memory segment, since no process references it anymore. All attach/detach/lock/unlock return always true.

The program runs for hrs and the code seems to be ok. Most of the time. But in my logs I see, that from time to time I get an error. The shared memory cannot be created, because it already exists. I can live with it, but it looks unclean to me. Could it be that there exists a race condition between the last detach() and a create()? 

Maybe it would be nice to have a signal, which tells, when a segment really is destroyed? OR course, if such a signal is even possible.


More information about the Interest mailing list