shmctl(2) — AT&T SYSTEM V
NAME
shmctl − shared memory control operations
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int shmctl (shmid, cmd, buf)
int shmid, cmd;
struct shmid_ds ∗buf;
DESCRIPTION
shmctl provides a variety of shared memory control operations as specified by cmd. The following cmds are available:
IPC_STAT Place the current value of each member of the data structure associated with shmid into the structure pointed to by buf. The contents of this structure are defined in intro(2). {READ}
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 only be executed by a process that has an effective user ID equal to that of super user, or to the value of shm_perm.cuid or shm_perm.uid in the data structure associated with shmidor the effective access vector of the user is ACC_IPCCTL.
If the user is super-user, the privilege ID of the shared memory is set to the numeric value contained in shm_perm.gid; otherwise, the privilege ID of the shared memory is set to the ID of a privilege containing the security label of the shared memory’s current privilege ID and the group of the privilege referred to by shm_perm.gid. (B1 only)
A shared memory’s privilege cannot be changed if the user’s real user ID is not root and the shared memory is attached to a process. (B1 only)
All shared memory reclassifications are audited.
IPC_RMID Remove the shared memory identifier specified by shmid from the system and destroy the shared memory segment and data structure associated with it. This cmd can only be executed by a process that has an effective user ID equal to that of super user, or to the value of shm_perm.cuid or shm_perm.uid in the data structure associated with shmid.
SHM_LOCK Lock the shared memory segment specified by shmid in memory. Pages of the segment not currently resident are faulted into memory and locked. A segment must be attached before it is locked. This cmd can only be executed by a process that has an effective user ID equal to super user or by a user which as an effective access vector of ACC_PLOCK.
SHM_UNLOCK Unlock the shared memory segment specified by shmid. This cmd can only be executed by a process that has an effective user ID equal to super user or by a user which as an effective access vector of ACC_PLOCK.
shmctl will fail if one or more of the following are true:
[EINVAL] Shmid is not a valid shared memory identifier.
[EINVAL] Cmd is not a valid command.
[EACCES] Cmd is equal to IPC_STAT and {READ} operation permission is denied to the calling process [see intro(2)].
[EPERM] Cmd is equal to IPC_RMID or IPC_SET and the effective user ID of the calling process is not equal to that of super user, or to the value of shm_perm.cuid or shm_perm.uid in the data structure associated with shmidor the user does not have the ACC_IPCCTL access vector. (If access vectors are configured).
[EPERM] Cmd is equal to SHM_LOCK or SHM_UNLOCK and the effective user ID of the calling process is not equal to that of super user or the user does not have the ACC_PLOCK access vector. (If access vectors are configured).
[EPERM] Cmd is equal to IPC_SET, the user’s current security label is not identical to the shared memory’s security label, and the user’s effective user ID is not super-user. (B1 only.)
[EPERM] Cmd is equal to IPC_SET, The shared memory’s privilege ID cannot be changed because the new group is not defined at the shared memory’s current security level, and the user is not super-user. (B1 only.)
[EPERM] Cmd is equal to IPC_SET, and the shared memory is attached to a process.
[EPERM] Cmd is equal to IPC_RMID, and the shared memory has not existed the minimum amount of time. (B1 only.)
[EFAULT] Buf points to an illegal address.
[ENOMEM] Cmd is equal to SHM_LOCK and there is not enough memory.
SEE ALSO
shmget(2), shmop(2).
ipcrm(1), ipcs(1), shmdefine(1) in the CX/UX User’s Reference Manual.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
NOTES
The user must explicitly remove shared memory segments after the last reference to them has been removed.
CX/UX Programmer’s Reference Manual