Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1064127
  • 博文数量: 284
  • 博客积分: 8223
  • 博客等级: 中将
  • 技术积分: 3188
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 13:26
文章分类

全部博文(284)

文章存档

2012年(18)

2011年(33)

2010年(83)

2009年(147)

2008年(3)

分类: C/C++

2009-06-09 09:03:27

#include
#include
#include
#include
#include
#include
#ifdef __sparc
#define  KEY  111111
#endif
#ifndef __sparc
#define  KEY 111111
#endif
#define SIZE_ 100
struct msgbuff
{
  long mtype;
  char mtext[ SIZE_ ];
}msgp;
void main(int argc, char ** argv[])
{
  int id;
  int fd;
  fd = msgget(KEY, IPC_CREAT | 0600);
  id = fork();
  if(id == 0) {
     sleep(3);
    msgrcv(fd, &msgp, SIZE_, 0, 0);
    printf("%s\n", msgp.mtext);
    msgctl(fd, IPC_RMID, NULL);
    return;
  
  }else {
     msgp.mtype = 1;
    strcpy(msgp.mtext, "I am cai");
    msgsnd(fd, &msgp, SIZE_, 0);
    return;
  }
}
阅读(400) | 评论(0) | 转发(0) |
0

上一篇:多进程环境

下一篇:mysql操作

给主人留下些什么吧!~~