加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

undefined reference to 'mq_open'

发布时间:2020-12-13 22:02:18 所属栏目:Linux 来源:网络整理
导读:验证 UNPv2里的一个例子时,连接时出现 undefined reference to 'mq_open' 错误。 man mq_open ,发现里面有这么一句话 :link with -lrt 。加上 -lrt 后,连接成功。 运行,出现 Permission deny。继续查,man mq_overview 发现: Each message queue is id

验证 UNPv2里的一个例子时,连接时出现 undefined reference to 'mq_open' 错误。

man mq_open ,发现里面有这么一句话 :link with -lrt 。加上 -lrt 后,连接成功。

运行,出现 Permission deny。继续查,man mq_overview 发现: Each message queue is identified by a name of the form /somename. 也就是说在指定 mqueue 的名字时,必须以 ”/" 开头,并且名字中只能有一个 “/"。UNPv2的 2.2 IPC names有详细的解释。

终于运行成功了,却发现找不到创建的 mqueue , 继续 man 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 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 system can be viewed and manipulated using the commands usually used for files (e.g.,ls(1) and rm(1)).

?????? The contents of each file in the directory consist of a single line containing information about the queue:

?????????? $ ls /dev/mqueue/mymq
?????????? QSIZE:129???? NOTIFY:2??? SIGNO:0??? NOTIFY_PID:8260
?????????? $ mount -t mqueue none /dev/mqueue

?????? These fields are as follows:

???????QSIZE?Number of bytes of data in all messages in the queue.

???????NOTIFY_PID
????????????? If this is non-zero,then the process with this PID has used mq_notify(3) to register for asynchronous message notification,and the remaining fields describe how notification occurs.

???????NOTIFY?Notification method: 0 is SIGEV_SIGNAL; 1 is SIGEV_NONE; and 2 is SIGEV_THREAD.

???????SIGNO?Signal number to be used for SIGEV_SIGNAL.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读