Results 1 to 2 of 2
I have a process that creates, open and attach a shared memory region in main().Then, I fork() that process ant I find i CAN directly use the inherited shared pointer ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-09-2013 #1
- Join Date
- Dec 2011
Are shared memory pointers valid through different processes?
It seems that,lets say, ptr=0x4f5000e in child process points to exactly the same shared memory region that it points in father process.
I would expect having to re-attach to same shared memory segment in my second process, but it seems is not needed.
Although this works, I´m not sure if not doing that re-attach would raise some problems when i put a C++ object in shared memory.
Should i attach child process to shared memory segment ? .If not, is that safe?
- 10-11-2013 #2
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
This should be save between forked processes. Another non-forked process will have to attach the shared memory segment separately as far as I understand. Read the man page on the fork() function for details as to which items are sharable between the processes. Some items are, and some are not.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!