shmat() & shmdt() questions.
TAYBENGH%NUSDISCS.BITNET at cunyvm.cuny.edu
TAYBENGH%NUSDISCS.BITNET at cunyvm.cuny.edu
Thu Sep 13 12:07:38 AEST 1990
I have 3 questions regarding usage of shared memory:
1) can a child process inherit shmid from parent? i.e. does the shmid
valid in the following program segment?
shmid = shmget(..);
if (fork() != 0)
{ /* parent process */
parent_shm = shmat(shmid, (char *)0, 0);
/* do sth on parent_shm */
.....
}
else
{ /* child process */
child_shm = shmat(shmid, (char *)0, 0);
/* do sth on child_shm */
.....
}
2) can a child inherit the virtual address return by shmat()?
for eg:
shmid = shmget(..);
addr = shmat(.shmid, (char *)0, 0);
if (fork() != 0)
{
/* do sth on addr */
...
}
else
{
/* can child sth on addr ??? */
.....
}
3) if a process quit without shmdt() the shared memory it attached
to, will the OS detect and decrement the shm_nattch in structure sgmid_ds?
Thanks a lot for the help.
- Beng Hang (email: taybengh at nusdiscs)
More information about the Comp.unix.internals
mailing list