Created
August 11, 2016 15:04
-
-
Save DeathTickle/aa8f980577d498850af4e819319636f9 to your computer and use it in GitHub Desktop.
Simple program to test creating a message queue with all permissions set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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