Go to the previous, next section.

shmctl

SYNOPSIS

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

PARAMETERS

shmid: [in] the memory segment to manipulate.

cmd: [in] the operation to perform.

buf: [in out] parameter for the operation (see description).

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
retreives the shmid_ds structure of the memory segment. The calling taks must have read privileges on the segment.

IPC_SET
sets the 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
mark the shared memory segment as destroyed. The calling taks must have the same uid of the creator or the owner of the memory segment or be the superuser.

SHM_LOCK
prevents the memory segment to be swaped out to disk. Only a task with superuser privileges may use this command.

SHM_UNLOCK
allows the memory segment to be swaped out to disk. Only a task with superuser privileges may use this command.

RETURN VALUE

On success, the call returns zero. On error -1 is returned and errno is set to one of the following values:

Go to the previous, next section.