【问题标题】:WSL : Function not implementedWSL:功能未实现
【发布时间】:2021-12-12 15:25:46
【问题描述】:

我知道 wsl 使用翻译要从 Windows 内核执行的每个命令,但我的问题仍然是:
WSL 是否支持系统调用(例如消息队列),如果支持,如何支持?强>

每当使用任何消息队列函数时,我都会收到“函数未实现”错误。还有希望吗?

[编辑:]

int main(int argc,char* argv[]){ 
    key_t key=MSG_KEY;
    mqid=msgget(key,0660 | IPC_CREAT );
    if(mqid==-1){
        perror("msgget error:");
        printf(" %s",strerror(errno));
    }
    int lenght=0,n=0;
    lenght=msgrcv(mqid,&req,MAX,1,0);
    if(lenght==-1){      
        if (errno == ENOMSG)
        {
            printf("\nNo message in the queue\n");
        }
        else
        {
            printf("\nError receiving message: %s\n", strerror(errno));
        }
    }
    else
    {
        printf("Received a message\n");
    }
    printf("\nreceived %d number of bytes\n",n);
    msgctl(mqid,IPC_RMID,NULL); 

    return 0;
}

【问题讨论】:

  • 向我们展示一段不起作用的代码。 WSL实际上是使用虚拟机,所以应该支持linux的所有功能。
  • @PMF,刚刚贴出代码
  • 你是否为msgctl添加了所需的头文件?
  • 第一句关于将 Linux 系统调用转换为 Windows NT 系统调用仅适用于 WSL 1。WSL 2 包含其自己的与 Windows NT 内核并行运行的 Linux 内核。
  • 您的 Windows 版本是否支持 WSL 2?如果是这样,可以将现有的 WSL 1 发行版转换为 WSL 2,这应该可以解决问题。

标签: c system windows-subsystem-for-linux


【解决方案1】:

WSL(1) 中缺少 System V IPC,这是 msgctl 所属的。

https://github.com/microsoft/WSL/issues/1016

【讨论】:

    猜你喜欢
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 2014-09-28
    • 2016-04-05
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多