Subject: Re: Wierd SYSV SHM behavior
To: None <smpatel@wam.umd.edu>
From: Charles M. Hannum <mycroft@ai.mit.edu>
List: tech-kern
Date: 04/19/1995 22:21:32
   >    Run by UID 100:
   > 	shmid = shmget(shmemKey, sizeof(struct memory), IPC_CREAT | 0666);
   > 	sharedMemory = (struct memory *) shmat(shmid, (char *) 0, 0);
   > 
   >    Run by UID 101:
   > 	if ((shmid = shmget (key, sizeof (struct memory), 666 )) < 0) {
   > 	    perror("shmget");
   > 	    exit(1);
   > 	}
   > 
   > This fails for me, even when I run both programs as the same uid.
   > That's because there's a typo in the second program.  I changed:
   > 
   >         if ((shmid = shmget (key, sizeof (struct memory), 666 )) < 0) {
   > 
   > to:
   > 
   >         if ((shmid = shmget (key, sizeof (struct memory), 0666 )) < 0) {

   You're right that is a typo on my part, but it shouldn't make a 
   difference when trying to attach to a shared memory segment that already 
   exists.  I tried it with 0600 and got the same results as before.

If you used 0600 in both programs, then of course it wouldn't work!
If you used 0666 in the program that created the segment, but 0600 in
the program trying to attach it, then I can't reproduce your problem
here.