elast0ny / shared_memory

A Rust wrapper around native shared memory for Linux and Windows
382 stars 51 forks source link

revoke ownership on fork #35

Closed gin66 closed 4 years ago

gin66 commented 5 years ago

Using shared memory for process forks lead to forked children calling shm_unlink. With this change, the ownership takes the pid into consideration. This patch changes the behaviour accordingly.

elast0ny commented 4 years ago

Hi, I like the idea of tying the shmem ownership with the PID to fix the issue with forking on Linux. Hopefully soon when i have time, I will look into adding this logic to the windows code also if required.

elast0ny commented 4 years ago

Hi, I have finally got to addressing the big safety issues related to the previous version of the crate.

This new version also allows callers to change ownership of the mapping through the Shmem::set_owner method which should provide what you need to fix your problems with forking.

Thanks !