shmctl()
shmctl() performs various shared memory operations:
int shmctl( int shmid, int cmd,
struct shmid_ds *buf );
cmd can be one of IPC_STAT, IPC_SET, or IPC_RMID:
- IPC_STAT fills the buf data structure (see <sys/shm.h>)
- IPC_SET can change the uid, gid, and mode of the shmid
- IPC_RMID sets up the shared memory segment to be removed from the system once the last process using the segment terminates or detached from it — a process detaches a shared memory segment using shmdt( void *addr ), which is similar to free()
shmctl() returns 0 if OK, -1 on error