首页 > 解决方案 > msgget 功能未实现

问题描述

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define  BUFF_SIZE   1024

typedef struct {
   long  data_type;
   int   data_num;
   char  data_buff[BUFF_SIZE];
} t_data;


int main(){

   key_t      msqid;
   int      ndx   = 0;
   t_data   data;


   msqid = msgget( (key_t)1234, IPC_CREAT | 0666);
   if ( -1 == msqid)
   {
      perror( "msgget() fail");
      exit( 1);
   }

   return 0;
}

接下来,我愿意

gcc -o parent parent.c

接下来,

./parent

但结果是

msgget() fail: Function not implemented

我不知道为什么 msgget 函数没有实现,即使这只是简单的代码。我该如何修复我的代码?

标签: clinuxoperating-systemipccommunication

解决方案


推荐阅读