Path: utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request From: klemets@sics.se (Anders Klemets) Newsgroups: comp.sys.sun Subject: Problem with shared memory on SunOS 4.1 Keywords: SunOS Message-ID: <568@brchh104.bnr.ca> Date: 30 Nov 90 21:16:17 GMT Sender: news@brchh104.bnr.ca Organization: Sun-Spots Lines: 22 Approved: Sun-Spots@rice.edu X-Original-Date: Fri, 23 Nov 90 18:30:21 GMT X-Sun-Spots-Digest: Volume 9, Issue 384, message 8 X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu 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@sics.se