VMS Help  —  CRTL  Shared Memory Routines, shmctl
    Shared memory control operations.

    Format

     #include <shm.h>

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

1  –  Arguments

 shmid

    A shared memory identifier, a positive integer. It is created
    by the shmget() function and used to identify the shared
    memory segment on which to perform the control operation.

 cmd

    The control operation (IPC_STAT, IPC_SET, or IPC_RMID) to perform
    on the shared memory segment. For more information, see the
    Description.

 buf

    Pointer to a shmid_ds structre, defined in <shm.h> as follows:

    struct shmid_ds {
    struct ipc_perm shm_perm; /* permissions structure defined in <ipc.h> */
    size_t shm_segsz;         /* size of memory segment in bytes */
    pid_t shm_lpid;           /* Process ID of last memory operation */
    pid_t shm_cpid;           /* Process ID of segment creator */
    shmatt_t shm_nattch;      /* Number of current attaches */
    time_t shm_atime;         /* time of last shmat */
    time_t shm_dtime;         /* time of last shmdt */
    time_t shm_ctime;         /* time of last change */
    }

2  –  Description

    The shmctl() function provides a variety of shared memory control
    operations as specified by the cmd argument. It can have the
    following values:

    IPC_STAT

        Place the current value of each member of the data structure
        associated with shmid into the structure pointed to by buf. The
        contents of this structure are defined in <shm.h>.

    IPC_SET

        Set the value of the following members of the data structureure
        associated with shmid to the corresponding value found in the
        structure pointed to by buf:

        shm_perm.uid
        shm_perm.gid
        shm_perm.mode /* only low 9 bits */

        This cmd can be executed by a process that has an effective
        user ID equal to either that of a user having appropriate
        privileges or to the value of either shm_perm.uid or
        shm_perm.cuid in the data structure associated with shmid.

        IPC_RMID

        Remove the shared memory identifier specified by shmid from the
        system and delete the shared memory segment and data structure
        associated with it. If the segment is attached to one or more
        processes, the segment key is changed to IPC_PRIVATE and the
        segment is marked as removed. The segment disappears when the
        last attached process detaches it. This cmd can be executed by
        a process that has an effective user ID equal to either that of
        a user with appropriate privileges or to the value of either
        shm_perm.uid or shm_perm.cuid in the data structure associated
        shmid.

3  –  Return Values

    0                 Successful completion.

    -1                Indicates an error. The function sets errno to one
                      of the following values:

                      o  EACCES - The argument cmd is equal to IPC_STAT
                         and the calling process does not have read
                         permission.

                      o  EINVAL - The value of shmid is not a valid
                         shared memory identifier, or the value of cmd
                         is not a valid command.

                      o  EFAULT - The argument cmd has value IPC_SET
                         but the address pointed to by buf is not
                         accessible.

                      o  EPERM - The argument cmd is equal to IPC_RMID
                         or IPC_SET and the effective user ID of the
                         calling process is not equal to that of a
                         process with appropriate privileges and it is
                         not equal to the value of shm_perm.cuid or
                         shm_perm.uid in the data structure associated
                         with shmid.

                      o  EVMSERR - OpenVMS specific non-translatable
                         error code.
Close Help