You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

QNX平台创建POSIX消息队列报错‘Function not implemented’求助

QNX平台创建POSIX消息队列报错“Function not implemented”的排查与解决

问题描述

我编写了如下代码创建POSIX消息队列,但运行时收到错误提示:“Function not implemented”。QNX平台应该支持消息队列,想知道原因是什么?

代码实现

#include <fcntl.h>
#include <mqueue.h>

#define DIAG_CLIENT "/DIAG_CLIENT"

#define MAX_MSG_SIZE 4096
#define MAX_MSGS 1024

mqd_t msg_queue = -1;
struct mq_attr attrs;

void
message_init()
{
    memset(&attrs, 0, sizeof(attrs));
    attrs.mq_maxmsg = MAX_MSGS;
    attrs.mq_msgsize = MAX_MSG_SIZE;
    msg_queue = mq_open(
      DIAG_CLIENT, O_RDWR | O_CREAT | O_NONBLOCK, S_IRWXU | S_IRWXG, &attrs);
    LOG("create or open msg_queue_log msg_queue:%d", msg_queue);
    if (msg_queue == -1) {
        ERR("create or open msg_queue failed! err=%d", errno);
    }
}

编译配置(common.mk)

LIBS += mq

排查与解决办法

  • 未加载POSIX消息队列资源管理器
    QNX的POSIX消息队列依赖mqueue资源管理器,默认未自动启动。需手动挂载或添加到启动脚本:
mount -T mqueue mqueue /dev/mqueue

将该命令加入系统启动脚本(如/etc/rc.d/rc.local),可实现开机自动加载。

  • 链接库依赖缺失
    部分QNX版本中,POSIX消息队列实现依赖线程库,建议修改编译配置:
LIBS += mq pthread
  • 消息队列名称格式问题
    部分QNX版本要求消息队列名称以/mq/开头,可尝试将DIAG_CLIENT修改为/mq/DIAG_CLIENT后重新测试。

  • 系统资源超限
    你设置的MAX_MSGS=1024和MAX_MSG_SIZE=4096可能超出系统默认限制。先尝试缩小参数值(如MAX_MSGS=128、MAX_MSG_SIZE=512),若能成功创建,再通过调整系统参数扩大资源限制。

内容的提问来源于stack exchange,提问作者xkou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 02:58:20