os_int32 os_destroyKeyFile( const char * name) { os_int32 result; os_sharedAttr shmAttr; os_sharedAttrInit(&shmAttr); result = 0; switch (shmAttr.sharedImpl) { case OS_MAP_ON_FILE: result = os_posix_destroyKeyFile(name); break; case OS_MAP_ON_SEG: result = os_svr4_destroyKeyFile(name); break; case OS_MAP_ON_HEAP: result = 0; break; } return result; }
/** \brief Destroy the POSIX shared memory object related to name * * First \b os_posix_sharedMemoryDestroy finds the shared object identifier * related to \b name by calling \b os_posix_getShmObjName. If the identifier is * found, the shared object is detroyed by calling \b shm_unlink. * After that the key file related to name is detroyed by calling * \b os_posix_destroyKeyFile. */ os_result os_posix_sharedMemoryDestroy ( const char *name) { char *shmname; os_result rv = os_resultSuccess; assert (name != NULL); shmname = os_posix_getShmObjName (name, NULL, 0); if (shmname != NULL) { if (shm_unlink (shmname) == -1) { OS_REPORT (OS_WARNING, "os_posix_sharedMemoryDestroy", 1, "shm_unlink failed with error %d (%s)", os_getErrno(), name); rv = os_resultFail; } if (os_posix_destroyKeyFile (name) == -1) { rv = os_resultFail; } os_free (shmname); } return rv; }