Subject: Re: Wierd SYSV SHM behavior
To: Charles M. Hannum <mycroft@ai.mit.edu>
From: Sujal Patel <smpatel@wam.umd.edu>
List: tech-kern
Date: 04/19/1995 21:02:16
On Wed, 19 Apr 1995, Charles M. Hannum wrote:

>    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 the 
same UID runs the two programs it succeeds, otherwise it fails?  This 
seems really odd to me, I don't know why it would do that?

Thanks



Sujal