Posix semaphore blocked by Mac Store sandbox
sem_open无法在Mac Store App中使用,会被sandbox denied,需要额外的权限,为保险起见,还是不要使用,免得被Apple拒了
以下代码无法通过
#include <semaphore.h> sem_t * pSemaphore = sem_open(name, O_CREAT, 0777, 1); if (pSemaphore == (sem_t *)SEM_FAILED) { //... }
用pthread_mutex替代
#include <pthread.h> pthread_mutex_t* pSemaphore = (pthread_mutex_t *)BL_MALLOC(sizeof(pthread_mutex_t)); int ret = pthread_mutex_init(pSemaphore, NULL); if (ret != 0) { //... }