Skip to content

Instantly share code, notes, and snippets.

@DeathTickle
Created August 11, 2016 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeathTickle/aa8f980577d498850af4e819319636f9 to your computer and use it in GitHub Desktop.
Save DeathTickle/aa8f980577d498850af4e819319636f9 to your computer and use it in GitHub Desktop.
Simple program to test creating a message queue with all permissions set
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <mqueue.h>
#define QUEUE_NAME "/my-mqueue"
#define QUEUE_SIZE 128
#define QUEUE_MSG_SIZE 64
int main(int argc, char **argv)
{
mqd_t my_mqueue;
struct mq_attr attr;
attr.mq_flags = 0;
attr.mq_maxmsg = QUEUE_SIZE;
attr.mq_msgsize = QUEUE_MSG_SIZE;
attr.mq_curmsgs = 0;
my_mqueue = mq_open(QUEUE_NAME, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, &attr);
if (my_mqueue == -1) {
perror("mq_open");
exit(-1);
}
if (mq_unlink(QUEUE_NAME) != 0) {
perror("mq_unlink");
exit(-1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment