Getting parent/child shared memory using mmap()

Getting parent/child shared memory using mmap()

Post by Ilya Klebano » Wed, 19 Jan 2000 04:00:00

Dear all,

I was trying to implement some code samples found in R.Stevens's bible. I
need some memory shared between parent and a child, and was hoping to get
away with mmap(), using either MAP_ANON flag or using open file handle

There is a piece of code ( I'm omitting any error control):
    int file;
    caddr_t pvAllocation;

    file = open( "/dev/zero",

    pvAllocation = mmap(  0,
                                        PROT_READ | PROT_WRITE,

    pvAllocation = mmap(  0,
                                        PROT_READ | PROT_WRITE,
                                        MAP_SHARED | MAP_ANON,

    close( file);


In both cases pvAllocation is returned as -1, and errno is set no EINVAL
file gets a valid descriptor number.

Any help will be highly appreciated.

Thank you,


1. Shared memory problrm between parent and child processes

Hi, there

I want to use shared memory to share data between parent process and the
child process it forks. I understand that the child just copy the data
segment from parent, but not pointing to the same place. I tried shm**
and sem** operations. But it dose not work as I expected. Semaphores are
in different processes. E.g. parent can do P on its semaphore, but child
can not do V on that semaphore. I know that I might make some mistake
or not quite understand the usage. Could anyone give some idea?

BTW, I am on solaris 2.5.1, which dose not support sem_init, sem_open,
etc, yet.


(Qiu, Ruibiao)
Telephone:            |  Email:

(O)(305)248-3740      |  Home Page:
(H)(305)220-9294      |

2. looking for shell account

3. sharing memory between parent/children

4. Cannot resolve name to ip address

5. Shared memory between Parent/Child process?

6. Xlib: connection to ":0.0" refused by server

7. Memory used by parent/child

8. Setting up a PPP server for FreeBSD

9. can a child munmap without destroying the parents mmap?

10. Trying to get shared memory using mmap?

11. Shared Memory using mmap

12. Getting children's PID with parent's pid?

13. Parent process getting child's environment?