X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ipc.c;h=ae9ad574bbd5840be8cee0c034c8f9e0e48cc7cc;hp=9ae2b3a09d1e1d98617e4502c16f7af2f0f54742;hb=c5517c98d28a74a89086b0641e3633d16eaf9df7;hpb=bad57eee70cdca87e8ba1af08d4e2ef6d2878620 diff --git a/ipc.c b/ipc.c index 9ae2b3a0..ae9ad574 100644 --- a/ipc.c +++ b/ipc.c @@ -11,7 +11,7 @@ int mutex_new(void) return ret < 0? -E_SEM_GET : ret; } -int mutex_remove(int id) +int mutex_destroy(int id) { int ret = semctl(id, 0, IPC_RMID); return ret < 0? -E_SEM_REMOVE : 1; @@ -92,12 +92,16 @@ int shm_destroy(int id) * * \sa semop(2) */ -void *shm_attach(int id, enum shm_attach_mode mode) +int shm_attach(int id, enum shm_attach_mode mode, void **result) { - if (mode == ATTACH_RW) - return shmat(id, NULL, 0); - return shmat(id, NULL, SHM_RDONLY); + if (mode == ATTACH_RW) { + *result = shmat(id, NULL, 0); + return *result? 1 : -E_SHM_ATTACH; + } + *result = shmat(id, NULL, SHM_RDONLY); + return *result? 1 : -E_SHM_ATTACH; } + int shm_detach(void *addr) { int ret = shmdt(addr);