shmat() & shmdt() questions.

Conor P. Cahill cpcahil at virtech.uucp
Thu Sep 13 22:17:04 AEST 1990


In article <13612 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (BURNS,JIM) writes:
>
>>         2) can a child inherit the virtual address return by shmat()?
>>            for eg:
>>                 shmid = shmget(..);
>>                 addr = shmat(.shmid, (char *)0, 0);
>
>This is dangerous. The proper method is for the child to also do a
>shmat(). On *some* OS's, the address returned by shmat() is the same in
>all processes, but virtual OS's, (or even ones that play w/ the MMU) might
>return different addresses, and the same address might mean different
>things to different procs.

This isn't dangerous.  Once the shared memory segment is attached it
is *supposed* to remain with the process (and therefore can move) even
through forks. (since we are talking about a fork, we must be talking
about the same kind of process and therefore there shouldn't be any
difference between the two process (other than the return of fork) unless
that vendor has broken something).


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.internals mailing list