- 论坛徽章:
- 0
|
下面这个程序为什么老是出错?
$ ./a.out /tmp.333
Wrong!
: Invalid argument
#include <mqueue.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <iostream>
using namespace std;
#define FILE_MODE S_IRUSR|S_IWUSR
struct mq_attr attr;
int main(int argc, char** argv){
int c, flags;
mqd_t mqd;
flags = O_RDWR|O_CREAT;
if( argc != 2){
printf("usage: mqcreate <name>\n");
return -1;
}
attr.mq_maxmsg = 512;
attr.mq_msgsize = 512;
mqd = mq_open( argv[argc -1 ], flags, FILE_MODE, &attr);
if(mqd < 0){
perror("Wrong!\n");
return -1;
}
mq_close(mqd);
exit(0);
} |
|