struct ipc_perms { uint32_t __key; uint32_t uid; uint32_t gid; uint32_t cuid; uint32_t cgid; uint32_t mode; uint32_t __seq; } struct shmid_ds { struct ipc_perms shm_perm; uint64_t shm_segsz; uint64_t shm_atime; uint64_t shm_dtime; uint64_t shm_ctime; uint32_t shm_cpid; uint32_t shm_lpid; uint64_t shm_nattch; } #define IPC_RMID 0 #define IPC_SET 1 #define IPC_STAT 2 int shmctl(int shmid, int cmd, struct shmid_ds *buf);
This syscall performs the control operation specified by cmd
on the
shared memory segment whose identifier is given in shmid
.
cmd
can be one of:
IPC_RMID
The passed shmid
is set to be deleted when the attached count of the
segment goes to 0
. Otherwise, it will linger forever. buf
is
ignored.
IPC_SET
Information passed on the structure pointed to by buf
is used to modify
the permission fields of the passed segment, namely shm_perm.uid
,
shm_perm.gid
, and shm_perm.mode
.
IPC_STAT
Get the associated information of the passed segment id and write it to the
structure pointed to by buf
.
The syscall returns 0
on success or -1
on failure, with the
following errno:
EINVAL
size
is less than needed and/or fd
is not a TTY.
EBADF
fd
is not opened to anything.
EFAULT
buffer
points to invalid memory.