l3.libnazgul/src/queueElemCreate.c

32 lines
648 B
C
Raw Normal View History

2004-02-23 21:01:59 +00:00
#include "libnazgul.h"
#include "ids.h"
2004-02-23 21:19:20 +00:00
int msgQueueElemCreate(msgQueueElemId,
finalQueueElemId,
msgQueueId queueId,
int counter){
2004-02-23 21:16:05 +00:00
msgQueueElemId queueElemId;
msgQueueElemIdIntern(queueElemId,queueId,counter);
2004-02-23 21:19:20 +00:00
strcpy(finalQueueElemId,queueElemId);
2004-02-23 21:16:05 +00:00
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);
2004-02-23 21:19:20 +00:00
goto ERROR;
2004-02-23 21:16:05 +00:00
}
if (ftruncate(queueElemFd, sizeof(msgQueueElem)) < 0){
2004-02-23 21:19:20 +00:00
NZG_ERROR("ftruncate", queueElemId);
2004-02-23 21:16:05 +00:00
goto ERROR;
}
2004-02-23 21:19:20 +00:00
2004-02-23 21:16:05 +00:00
close(queueElem_Fd);
return 0;
ERROR:
return -1;
2004-02-23 21:01:59 +00:00
}