#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;
}
}
阅读(429) | 评论(0) | 转发(0) |