[comp.unix.ultrix] Problems with shmat

wielemak@serc.nl (Jan Wielemaker) (10/11/90)

Hi,

I'm trying to attach a shared memory segment at a specific address.
The first time everything is fine, but the second time I want to
attach another shared memory segment at the same address (after
detaching the first) shmat() returns EINVAL.

I want to use this to enlarge a private shared memory segment.
Schematic:

  ....
  id = shmget(IPC_PRIVATE, size, S_IRUSR|S_IWUSR);
  shmat(id, addr, 0);
  shmctl(id, IPC_RMD, NULL);
  ...
  <later>
  ...
  id2 = shmget(IPC_PRIVATE, size2, S_IRUSR||S_IWUSR);
  addr2 = shmat(id2, NULL, 0);
  bcopy(addr, addr2, size);

  shmdt(addr);
  shmdt(addr2);
  shmat(id2, addr, 0); ---> EINVAL
  

This is schematic; in the actual code all calls are checked for their
return value and everything is initialised to sensible values.

I am using Ultrix 3.1C on a DEC-system 5400 (MIPS).

	Please reply by mail (wielemak@serc.nl),
	
	Thanks for any clue you can give me,
	
	Jan