无法在 Windows 的 Linux 子系统中创建消息队列

Can't create message queue in Linux subsystem on Windows

我尝试在 Windows 10 中的 linux 子系统上创建消息队列。 当我尝试使用此函数创建消息队列时:

 queueId = msgget(*key, IPC_CREAT | IPC_EXCL | 0660);
    if (queueId == -1)
    {
        if (errno == EEXIST)
        {
            queueId = msgget(*key, IPC_CREAT | 0660);
            printf("Messege queue already exists, access acquired\n");
            return;
        }
        else
        {
            printf("Couldn't create message queue. Process ended with error: %d\n", errno);
            exit(EXIT_FAILURE);
        }
    }
    else
    {
        printf("Message queue has been created with id: %d\n", queueId);
    }

我收到错误编号 38,即 ENAMETOOLONG。在这种情况下我能做什么?

根据this github issue,WSL 不支持 SysV 消息队列。您需要切换到 WSL2,一个适当 VM 中的 Linux 实例 运行,或者寻找不同的方法。