shmctl (2) - Linux Manuals
shmctl: System V shared memory control
Command to display shmctl
manual in Linux: $ man 2 shmctl
NAME
shmctl - System V shared memory control
SYNOPSIS
#include <sys/ipc.h>
#include <sys/shm.h>
int shmctl(int shmid, int cmd, struct shmid_ds *buf);
DESCRIPTION
shmctl()
performs the control operation specified by
cmd
on the System V shared memory segment whose identifier is given in
shmid.
The
buf
argument is a pointer to a shmid_ds structure,
defined in <sys/shm.h> as follows:
struct shmid_ds {
struct ipc_perm shm_perm; /* Ownership and permissions */
size_t shm_segsz; /* Size of segment (bytes) */
time_t shm_atime; /* Last attach time */
time_t shm_dtime; /* Last detach time */
time_t shm_ctime; /* Creation time/time of last
modification via shmctl() */
pid_t shm_cpid; /* PID of creator */
pid_t shm_lpid; /* PID of last shmat(2)/shmdt(2) */
shmatt_t shm_nattch; /* No. of current attaches */
...
};
The fields of the
shmid_ds
structure are as follows:
- shm_perm
-
This is an
ipc_perm
structure (see below) that specifies the access permissions
on the shared memory segment.
- shm_segsz
-
Size in bytes of the shared memory segment.
- shm_atime
-
Time of the last
shmat(2)
system call that attached this segment.
- shm_dtime
-
Time of the last
shmdt(2)
system call that detached tgis segment.
- shm_ctime
-
Time of creation of segment or time of the last
shmctl()
IPC_SET
operation.
- shm_cpid
-
ID of the process that created the shared memory segment.
- shm_lpid
-
ID of the last process that executed a
shmat(2)
or
shmdt(2)
system call on this segment.
- shm_nattch
-
Number of processes that have this segment attached.
The
ipc_perm
structure is defined as follows
(the highlighted fields are settable using
IPC_SET):
struct ipc_perm {
key_t __key; /* Key supplied to shmget(2) */
uid_t uid; /* Effective UID of owner */
gid_t gid; /* Effective GID of owner */
uid_t cuid; /* Effective UID of creator */
gid_t cgid; /* Effective GID of creator */
unsigned short mode; /* Permissions + SHM_DEST and