shmat()
Once a shared memory segment has been created, a process attaches it to its address space by calling shmat():
void *shmat( int shmid, void *addr, int flag );
shmat() returns pointer to shared memory segment if OK, -1 on error
The recommended technique is to set addr and flag to zero, i.e.:
char *buf = (char *) shmat( shmid, 0, 0 );
The UNIX commands “ipcs” and “ipcrm” are used to list and remove shared memory segments on the current machine
The default action is for a shared memory segments to remain in the system even after the process dies -- a better technique is to use shmctl() to set up a shared memory segment to remove itself once the process dies ( … see next slide)