C语言消息队列
MsgQueue1.c
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#define KEY 1234
struct msgbuf
{
long mtype; /* message type, must be > 0 */
char mbuf[100]; /* message data */
};
//typedef struct msgbuf buf;
int main()
{
int msgid,ret;
pid_t pid;
struct msgbuf buf;
msgid = msgget(KEY,IPC_CREAT | IPC_EXCL);
if(-1 == msgid)
{
perror("msgget");
exit(1);
}