shmctl(2) shmctl(2)
NAME
shmctl - shared memory control functions
SYNOPSIS
#include <sys/shm.h>
int shmctl(int shmid, int cmd, struct shmidds *buf);
DESCRIPTION
shmctl() provides control operations for shared memory. The following
control operations can be specified by cmd.
IPCSTAT Places the current value of each member of the data
structure associated with shmid into the structure
pointed to by buf. The contents of the structure are
defined in sys/shm.h.
IPCSET Sets 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:
shmperm.uid
shmperm.gid
shmperm.mode /* only access permission bits */
This function can be executed only by a process that has
an effective user ID equal to that of superuser, or to
the value of shmperm.cuid or shmperm.uid in the data
structure associated with shmid.
IPCRMID Removes the shared memory identifier specified by shmid
from the system and destroy the shared memory segment and
data structure associated with it. This function can be
executed only by a process that has an effective user ID
equal to that of superuser, or to the value of
shmperm.cuid or shmperm.uid in the data structure asso-
ciated with shmid.
SHMLOCK Locks the shared memory segment specified by shmid in
memory. This function can be executed only by a process
that has an effective user ID equal to superuser.
SHMUNLOCK Unlocks the shared memory segment specified by shmid.
This function can be executed only by a process that has
an effective user ID equal to superuser.
Page 1 Reliant UNIX 5.44 Printed 11/98
shmctl(2) shmctl(2)
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
shmctl() fails if one or more of the following apply:
EACCES cmd is equal to IPCSTAT and operation permission is
denied to the calling process.
EINVAL shmid is not a valid shared memory identifier.
EINVAL cmd is not a valid command.
EINVAL cmd is IPCSET and shmperm.uid or shmperm.gid is not
valid.
EOVERFLOW cmd is IPCSTAT and uid or gid is too large to be stored
in the structure pointed to by buf.
EPERM cmd is equal to IPCRMID or IPCSET and the effective
user ID of the calling process is not equal to that of
superuser, or to the value of shmperm.cuid or
shmperm.uid in the data structure associated with shmid.
EPERM cmd is equal to SHMLOCK or SHMUNLOCK and the effective
user ID of the calling process is not equal to that of
superuser.
EFAULT buf points to an illegal address.
ENOMEM cmd is equal to SHMLOCK and there is not enough memory.
RESULT
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.
In the future there may be modifications to the interfaces for inter-
process communication. You should design your applications so that in
modules using shmctl() this function can easily be replaced by others.
SEE ALSO
shmget(2), shmop(2), shm(5).
Page 2 Reliant UNIX 5.44 Printed 11/98