PDA

View Full Version : [SOLVED] sharing memory between child and parent in fork()



tornado89
June 24th, 2008, 05:20 PM
How Can I Share The Same Memory Page Between A Parent
And It's Child Created Using fork();

I Know That vfork() can Do That But The Parent Must Wait
Till The Child calls exec()... Which Is NON-SENSE To Me

BTW I Am Using C++
Thanks ........

JupiterV2
June 24th, 2008, 05:46 PM
I am only a beginner in this particular subject but I know that in C you can use mmap() to share memory between processes.

PaulFr
June 24th, 2008, 06:36 PM
I presume you are aware of the items inherited by the child process on fork(); if not, please see 1.1.1 in Unix Programming FAQ (http://www.faqs.org/faqs/unix-faq/programmer/faq/)

If you need to share info after the fork() call - you can use shared memory, mmap, pipes, named pipes, sockets, message queues, semaphores and even signals (see http://www.ibm.com/developerworks/aix/library/au-ipc/ and http://en.wikipedia.org/wiki/Mmap) for an introduction.

tornado89
June 25th, 2008, 07:05 AM
thanks... mmap() was what i am looking for..