日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【学习随手记】POSIX消息队列执行报Permission denied的问题。

發布時間:2025/3/13 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【学习随手记】POSIX消息队列执行报Permission denied的问题。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近學習UNIX環境網絡編程POSIX消息隊列的時候發現一個問題,在mq_open的時候總會報Permission denied的錯誤。

查看mq_overview后才得以解決。

mq_overview原文描述如下:

Mounting the message queue file system
?????? On Linux, message queues are created in a virtual file system.?? (Other
?????? implementations? may? also? provide such a feature, but the details are
?????? likely to differ.)? This file system can be mounted (by the? superuser)
?????? using the following commands:

?????????? # mkdir /dev/mqueue
?????????? # mount -t mqueue none /dev/mqueue

?????? The sticky bit is automatically enabled on the mount directory.

?????? After? the file system has been mounted, the message queues on the sys‐
?????? tem can be viewed and manipulated using the commands usually? used? for
?????? files (e.g., ls(1) and rm(1)).

創建MQ的代碼如下:

1 #include <unpipc.h> 2 3 int 4 main(int argc, char **argv) 5 { 6 int c, flags; 7 mqd_t mqd; 8 9 flags = O_RDWR | O_CREAT; 10 11 while ((c = Getopt(argc, argv, "e")) != -1) 12 { 13 switch (c) 14 { 15 case 'e': 16 flags |= O_EXCL; 17 break; 18 } 19 } 20 21 if (optind != argc - 1) 22 err_quit("usage: mqcreate [-e] <name>"); 23 24 mqd = Mq_open(argv[optind], flags, 0777, NULL); 25 Mq_close(mqd); 26 27 exit(0); 28 }

?

轉載于:https://www.cnblogs.com/zhiqli/p/3487638.html

總結

以上是生活随笔為你收集整理的【学习随手记】POSIX消息队列执行报Permission denied的问题。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。