Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

54. POSIX Shared Memory > Removing Shared Memory Objects

Removing Shared Memory Objects

SUSv3 requires that POSIX shared memory objects have at least kernel persistence; that is, they continue to exist until they are explicitly removed or the system is rebooted. When a shared memory object is no longer required, it should be removed using shm_unlink().

#include <sys/mman.h>

int shm_unlink(const char *name);

Note

Returns 0 on success, or -1 on error

The shm_unlink() function removes the shared memory object specified by name. Removing a shared memory object doesn’t affect existing mappings of the object (which will remain in effect until the corresponding processes call munmap() or terminate), but prevents further shm_open() calls from opening the object. Once all processes have unmapped the object, the object is removed, and its contents are lost.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint