VMS Help  —  CRTL  Shared Memory Routines, shmdt
    Shared memory detach operation.

    Format

     #include <shm.h>

     int shmdt(const void *shmaddr);

1  –  Arguments

 shmaddr

    The address returned by a previous call to shmat.

2  –  Description

    The shmdt() function detaches the shared memory segment located at
    the address specified by shmaddr from the address space of the
    calling process.

    The to-be-detached segment must be currently attached with shmaddr
    equal to the value returned by the attaching shmat() function.

    On a successful shmdt() function the system updates the members of
    the shmid_ds structure associated with the shared memory segment as
    follows:

        o  shm_dtime is set to the current time.
        o  shm_lpid is set to the process-ID of the calling process.
        o  shm_nattch is decremented by one. If it becomes zero and the
           segment is marked for deletion, the segment is deleted.
           For more information see the shmctl function.

    Upon exit, all the attached shared memory segments are detached
    from the process.

3  –  Return Values

    0                 Successful completion.

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

                      o  EINVAL - The value of shmaddr is not the data
                         segment address of a shared memory segment.

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