Home:ALL Converter>How to avoid shared memory leaks

How to avoid shared memory leaks

Ask Time:2014-03-27T23:05:52         Author:Rom098

Json Formatter

I'm using shared memory between 2 processes on Suse Linux and I'm wondering how can I avoid the shared memory leaks in case one process crashes or both. Does a leak occur in this case? If yes, how can I avoid it?

Author:Rom098,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22691621/how-to-avoid-shared-memory-leaks
John Zwinck :

You could allocate space for two counters in the shared memory region: one for each process. Every few seconds, each process increments its counter, and checks that the other counter has been incremented as well. That makes it easy for these two processes, or an external watchdog, to tear down the shared memory if somebody crashes or exits.",
2014-03-27T15:10:07
yy