我正在尝试编写一个在Micokernel和Monolithic系统上实现消息传递的应用程序。这段代码在Linux上运行得很好但在Denbian GNU / Hurd上失败
#include <sys/types.h>
#include <sys/msg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MSGSZ 128
/*
* Declare the message structure.
*/
typedef struct msgbufer {
long mtype;
char mtext[MSGSZ];
} message_buf;
int main()
{
int msqid;
int msgflg = IPC_CREAT | 0666;
key_t key;
message_buf sbuf;
size_t buf_length;
/*
* Get the message queue id for the
* "name" 1234, which was created by
* the server.
*/
key = 1234;
(void) fprintf(stderr, "\nmsgget: Calling msgget(%i,\
%#o)\n",
key, msgflg);
if ((msqid = msgget(key, msgflg )) < 0) {
perror("msgget");
exit(1);
}
else
(void) fprintf(stderr,"msgget: msgget succeeded: msqid = %d\n", msqid);
/*
* We'll send message type 1
*/
sbuf.mtype = 1;
(void) strcpy(sbuf.mtext, "Hello other process 2.");
buf_length = strlen(sbuf.mtext) + 1 ;
/*
* Send a message.
*/
int err = msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT);
if (err < 0) {
printf ("%d, %li, %s, %lu\n", msqid, sbuf.mtype, sbuf.mtext, buf_length);
perror("msgsnd");
exit(1);
}
else
printf("Message: \"%s\" Sent\n", sbuf.mtext);
exit(0);
}
这是我得到的错误:
send.cpp: (.text+0xf9): warning: msgsnd is not implemented and will always fail
send.cpp: (.text+0xf9): warning: msgget is not implemented and will always fail
有什么想法吗?