Handle multiple processes.

When a fork is done, the child inherits shm information from its father, but need to update the reference counter otherwise the shm segment may be destroyed too
soon.

Add an assert to check wrong refcounter values and a test which triggers the assert without the fix.