shmctl()

perform shared memory control operations 

Function


SYNOPSIS

#include <sys/shm.h>

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


DESCRIPTION

The shmctl() function provides a variety of shared memory control operations as specified by cmd. The following commands are available:

IPC_STAT 

Copies the current attributes of the shared memory segment associated with shmid into the structure that buf points to.

IPC_SET 

Sets the attributes of the shared memory segment associated with shmid from the values found in the structure that buf points to:

shm_perm.uid
shm_perm.gid
shm_perm.mode    /* only access permission bits */

This command can be executed only by a process that has an effective user ID equal to that of super user, shm_perm.cuid, or shm_perm.uid.

IPC_RMID 

Removes the shared memory identifier that shmid specifies from the system and destroys the shared memory segment. This command can be executed only by a process that has an effective user ID equal to that of super user, shm_perm.cuid, or shm_perm.uid.


PARAMETERS

shmid 

Is a unique positive integer returned by the shmget() function and associated with a segment of memory and a data structure.

cmd 

Specifies one of IPC_STAT, IPC_SET, or IPC_RMID.

buf 

Points to the data structure used for sending or receiving data during execution of shared memory control operations.


RETURN VALUES

If successful, shmctl() returns zero. On failure, it returns -1 and sets errno to one of the following values:

EACCES 

cmd is equal to IPC_STAT and the calling process does not have read permission.

EFAULT 

buf points to an illegal address.

EINVAL 

cmd is IPC_SET, and shm_perm.uid or shm_perm.gid is not valid.

cmd is not a valid command.

shmid is not a valid shared memory identifier.

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, shm_perm.cuid, or shm_perm.uid.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
shmat(), shmdt(), shmget()


PTC MKS Toolkit 10.5 Documentation Build 40.