Go to the previous, next section.
int shmctl(int shmid, int cmd, struct shmid_ds
*buf);
shmid: [in] the memory segment to manipulate.
cmd: [in] the operation to perform.
buf: [in out] parameter for the operation (see description).
This calls manipulates some operational parameters of shared memory
segments. The shmid_ds structure has the following layout:
struct shmid_ds {
        struct  ipc_perm shm_perm;      /* operation perms */
        int     shm_segsz;              /* size of segment (bytes) */
        time_t  shm_atime;              /* last attach time */
        time_t  shm_dtime;              /* last detach time */
        time_t  shm_ctime;              /* last change time */
        unsigned short  shm_cpid;       /* pid of creator */
        unsigned short  shm_lpid;       /* pid of last operator */
        short   shm_nattch;             /* no. of current attaches */
        /* the following are private */
        unsigned short   shm_npages;  /* size of segment (pages) */
        unsigned long   *shm_pages;   /* array of ptrs to frames -> SHMMAX */ 
        struct shm_desc *attaches;    /* descriptors for attaches */
};
cmd can take the following values:
IPC_STAT
shmid_ds structure of the memory segment. The
calling taks must have read privileges on the segment.
IPC_SET
shmid_ds structure of the memory segment. The calling
task must have alter privileges on the segment. Only the members
uid, gid and the lower 9 bits of mode of
shm_perm can be modified.
IPC_RMID
SHM_LOCK
SHM_UNLOCK
On success, the call returns zero. On error -1 is returned and
errno is set to one of the following values:
EINVAL: shmid or cmd are not valid.
EPERM: the calling task does not have enough privileges on
the memory segment to perform the operation.
EFAULT or EIDRM.
Go to the previous, next section.