shmctl() COHERENT System Call shmctl() Control shared-memory operations #include <sys/shm.h> shmctl(shmid, cmd, buf) int shmid, cmd; struct shmid_ds *buf; shmctl provides controls the COHERENT system's shared-memory facility. cmd specifies the operation to perform, as follows: IPC_STAT Place the current value of each member of the data structure associated with shmid into the structure pointed to by buf. IPC_SET Set the value of the following members of the data structure associated with shmid to the corresponding value found in the structure pointed to by buf: shm_perm.uid shm_perm.gid shm_perm.mode /* only low 9 bits */ This cmd can be executed only by a process whose ef- fective user ID equals either that of the superuser or shm_perm.uid in the data structure associated with shmid. IPC_RMID Remove the system identifier specified by shmid from the system and destroy the shared memory segment and data structure associated with it. This cmd can be ex- ecuted only by a process whose effective user ID equalS either that of the superuser or shm_perm.uid in the data structure associated with shmid. shmctl fails if any of the following is true: * shmid is not a valid shared memory identifier shmget sets er- rno to EINVAL. * cmd is not a valid command (EINVAL). * cmd equals IPC_STAT and operation permission is denied to the calling process (EACCES). * cmd equals IPC_RMID or IPC_SET and the effective user iden- tifier of the calling process does equals neither that of the superuser nor shm_perm.uid in the data structure associated with shmid (EPERM). * buf points to an illegal address (EFAULT). ***** Return Value ***** Upon successful completion, shmctl returns zero; otherwise, it returns -1 and sets errno to an appropriate value. COHERENT Lexicon Page 1
shmctl() COHERENT System Call shmctl() ***** Files ***** /usr/include/sys/ipc.h /usr/include/sys/shm.h /dev/shm /drv/shm ***** See Also ***** COHERENT system calls, shm, shmget() ***** Notes ***** To improve portability, the COHERENT system implements its shared-memory functions as a device driver instead of as an ac- tual system call. COHERENT Lexicon Page 2