Unlinking a program from a shared memory segmentΒΆ

unlink_shared_memory()

Unlinking a program from a shared memory segment


SYNTAX

unlink_shared_memory(shm_id)

Unlink this program from the shared memory segment specified in shm_id. This is the return value from the function that created or linked to the segment. Avoid creating a second open link to the same shared memory segment in the same program. If this is done, it is necessary to unlink twice, once with each shm_id.

When all programs, including the one that created the segment, have unlinked it or exited, the shared memory is released (except when created with the SHM_PERSIST option).


EXAMPLE

!record Messages {
     fieldlist
}

!temp MemNo,,i4

     MemNo = link_shared_memory("shmseg001", Messages)
     if (MemNo == 0) {
          error "Error linking to shared memory segment: errno = " + tostr(sys.Errno)
          exit
     }

     ...

!function wintaskEvent(EventCode) {
     switch (EventCode) {
     case == EV_CLOSE:
          unlink_shared_memory(MemNo)
          exit
     }
}

Shared memory functions

create_shared_memory()

Create a shared memory segment

link_shared_memory()

Link to an existing shared memory segment

read_shared_memory()

Read the current field values from shared memory into associated record buffer

write_shared_memory()

Write the current values from associated record buffer into shared memory

unlock_shared_memory()

Unlock a shared memory segment

unlink_shared_memory()

Unlink a program from a shared memory segment


RELATED TOPICS

Shared memory options in sculptor.h

!record

![o]file