#include <iostream> #include <fcntl.h> #include <sys/stat.h> #include <mqueue.h> #include <string.h> using namespace std; const string QueueName{"/DemoQueue"}; int main(int argc, char * argv[]) { int flags {O_WRONLY}; mqd_t queue = mq_open(QueueName.c_str(), flags); if(queue == -1) { perror("mq_open:"); } size_t len; for(int i = 1; i < argc; ++i) { len = mq_send(queue, argv[i], strlen(argv[i]), i); } mq_close(queue); return 0; }