shmctl()

NAME

shmctl() - control shared memory operations

SYNOPSIS

#include <sys/shm.h>

int shmctl(int shmid, int cmd, struct shmid_ds *buf)

DESCRIPTION

The shmctl(2) function gives you access to the data information associated with a shared memory segment, either to read or set the values of members, or to remove a shared memory identifier. argument.

The function parameters are:

shmid
An identifier for the shared memory segment. The shared memory segment has a shmid_ds data structure associated with it; see <sys/shm.h> for a description of the structure.
cmd
The operation to be performed. The following are valid (defined in <sys/shm.h>):
IPC_STAT
Copies the current values of the shmid_ds data structure associated with shmid into buf.
IPC_SET
Sets the value of members of the shmid_ds data structure associated with shmid from the same members in buf. The members copied are sh_perm.uid sh_perm.gid and the low-order nine bits of shm_perm.mode
IPC_RMID
Removes the identifier specified by shmid from the system and destroys the shared memory segment and data structure associated with it.
buf
The buffer used to store information copied or to be copied.

The header file <sys/shm.h> includes <sys/ipc.h>.

RETURN VALUE

The shmctl(2) call returns 0 on success. On failure, it returns -1 and sets errno

ERRORS

The shmctl(2) function can fail for the following reasons:

[EACCES]
The cmd is IPC_STAT and the calling process doesn't have read permission.
[EINVAL]
Shmid is not a valid shared memory identifier.
[ENOSYS]
The function isn't implemented.
[EPERM]
The cmd is IPC_RMID or IPC_SET and the calling process doesn't the appropriate privileges (that is, the ones set by shm_perm.cuid or shm_perm.uid in the data structure associated with shmid).

The function may fail because of:

[EOVERFLOW]
The cmd is PC_STAT and the value of gid or uid is too large to be stored in the structure indicated by buf.

SEE ALSO

shmat(2)

shmdt(2)

shmget(2)