fork question

In my main function I create and link to a global shared memory area, then I
fork the program to create a number of other child processes.

Is there any reason to re-link to the shared memory area from each child
process? Will program stability be improved?

Thanks in Advance

Dan

Daniel Carreira <carreira@nir_vivo.com> wrote:

In my main function I create and link to a global shared memory area, then I
fork the program to create a number of other child processes.
Is there any reason to re-link to the shared memory area from each child
process? Will program stability be improved?

Depending on how you’re shared memory is setup, when you mmap() the shared region
in the parent you should specify the MAP_SHARED flag, so that the mappings are
preserved when you fork() (ie. the child will have the same mappings).

-Adam