-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy path01mqopen.cpp
More file actions
39 lines (32 loc) · 732 Bytes
/
01mqopen.cpp
File metadata and controls
39 lines (32 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Created by jxq on 19-8-14.
//
// p34 poxis消息队列
#include <errno.h>
#include <unistd.h>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <mqueue.h>
using namespace std;
#define ERR_EXIT(m) \
do \
{ \
perror(m); \
exit(EXIT_FAILURE); \
} while (0);
int main(int argc, char** argv)
{
// mq_overview
mqd_t mqid = mq_open("/abc", O_CREAT | O_RDWR, 0666, NULL);
if (mqid == ((mqd_t) -1))
{
ERR_EXIT("mq_open");
}
printf("mqopen success\n");
mq_close(mqid);
printf("mqclose success\n");
return 0;
}