Hi guys.
i have wrote a simple program to test message queue attributes. here it is:
#include <stdio.h>
#include <stdlib.h>
#include <mqueue.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
int main()
{
struct mq_attr attr;
mqd_t mqd;
if ((mqd = mq_open("/tmp/queue.123", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, NULL)) == -1)
{
printf("damn it: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
mq_getattr(mqd, &attr);
printf("max message on queue: %ld\n", attr.mq_maxmsg);
printf("max message size: %ld\n", attr.mq_msgsize);
printf("current number of message on the queue: %ld\n", attr.mq_curmsgs);
mq_close(mqd);
mq_unlink("/tmp/queue.123");
return EXIT_SUCCESS;
}
but when i run it always it prints:
damn it: Permission denied
I executed it under root user but again this error.
also permissions for /tmp directory is 777.