Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!news From: TAYBENGH%NUSDISCS.BITNET@cunyvm.cuny.edu Newsgroups: comp.unix.internals Subject: shmat() & shmdt() questions. Message-ID: <24482@adm.BRL.MIL> Date: 13 Sep 90 02:07:38 GMT Sender: news@adm.BRL.MIL Lines: 40 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@nusdiscs)