l3.libnazgul/src/queueOpen.c

29 lines
508 B
C

#include "libnazgul.h"
#include "ids.h"
void * msgQueueOpen(msgQueueId queueId){
int queueFd;
void * queueAddr;
queueFd=shm_open(queueId,O_RDWR,SHM_DEFAULT_MODE);
if (queueFd == -1 ) {
NZG_ERROR("shm_open : msgQueue open",queueId);
goto ERROR;
}
queueAddr=mmap(NULL,
sizeof(msgQueue),
PROT_READ|PROT_WRITE,
MAP_SHARED,
queueFd,
0);
if( queueAddr == MAP_FAILED ) {
NZG_ERROR("mmap",queueId);
goto ERROR;
}
close(queueFd);
return queueAddr;
ERROR:
return NULL;
}