//进程1
int msg_id = -1;
if((msg_id = msgget((key_t)MSG_R_KEY, 0777|IPC_CREAT)) == -1 ) //创建或者获取KEY值的消息队列
{
printf("msgget failure!!!\n");
return (-1);
}
if((msgsnd(msg_id, (void *)&msg_q_s, sizeof(struct r_msg_t), 0)) == -1) //发送消息
{
printf("msgsnd failure!!!\n");
return (-1);
}
//进程2
int msg_id = -1;
if((msg_id = msgget((key_t)MSG_R_KEY, 0777|IPC_CREAT)) == -1 )
{
printf("msgget failure!!!\n");
return (-1);
}
if(msgrcv(msg_id,(void *)&msg_q_r, sizeof(struct re_msg_t), msg_rx, 0) == -1) //接收消息
{
printf("msgrcv failure!!!\n");
}
[linux系统编程]System V IPC 消息队列
猜你喜欢
转载自blog.csdn.net/mingtianyueni/article/details/18730579
今日推荐
周排行