Problem with shared memory on SunOS 4.1

Anders Klemets klemets at sics.se
Sat Dec 1 08:16:17 AEST 1990


I have a client/server application that uses shared memory. The shared
memory segment must be mapped onto the same address by all participating
processes. A client attaches the shared memory segment with

	id = shmget(key, 0, 0);
	addr = shmat(id, 0, 0);

This will make the kernel choose on which address to put the shared memory
segment. This usually turns out to be the "right" address. But if not, I
detach the segment and attach it at the right address with

	shmdt(addr);
	addr = shmat(id, rightaddr, 0);

At this point the call to shmat() always fails on a Sun-4 with SunOS 4.1
It returns with errno: "invalid argument." I have never experienced that
this code would fail on SunOS 4.0.3 or on System V release 3.2. 

What could be wrong? It seems unlikely that the memory pointed at by
"rightaddr" would be in use by some other part of the process.

Anders Klemets			klemets at sics.se



More information about the Comp.sys.sun mailing list