l3.libnazgul/src/queueElemCreate.c
2020-03-03 23:46:32 +01:00

31 lines
647 B
C

#include "libnazgul.h"
#include "ids.h"
int msgQueueElemCreate(
msgQueueElemId finalQueueElemId ,
msgQueueId queueId,
int counter){
msgQueueElemId queueElemId;
msgQueueElemIdIntern(queueElemId,queueId,counter);
strcpy(finalQueueElemId,queueElemId);
int queueElemFd;
queueElemFd=shm_open(queueElemId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
SHM_DEFAULT_MODE);
if (queueElemFd == -1 ) {
NZG_ERROR("shm_open : msgQueueElem creation",queueElemId);
goto ERROR;
}
if (ftruncate(queueElemFd, sizeof(msgQueueElem)) < 0){
NZG_ERROR("ftruncate", queueElemId);
goto ERROR;
}
close(queueElemFd);
return 0;
ERROR:
return -1;
}