/*ide
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <unistd.h>函數
int main(int argc, char argv[])
{
int gflags,sflags,rflags;
key_t key;
int msgid;
int reval;
struct msgsbuf
{
int mtype;
char mtext[20];
}msg_sbuf;
struct msqid_ds msg_ginfo,msg_sinfo;
char msgpath="/unix/msgqueue";
gflags=IPC_CREAT|IPC_EXCL;
key=ftok(msgpath,'a');
msgid=msgget(key,gflags|00666);
if(msgid==-1)
{
printf("msg create error\n");
return ;
}
sflags=IPC_NOWAIT;
msg_sbuf.mtype=10;
msg_sbuf.mtext[20]="hello! This is a test!";
reval=msgsnd(msgid,&msg_sbuf,sizeof(msg_sbuf.mtext),sflags);
if(reval==-1)
printf("message send error\n");
return 0;
}unix