#include <sys/types.h>
#include <sys/msg.h>
#include <unistd.h>
void msg_stat(int,struct msqid_ds );
void main()
{
int gflags,sflags,rflags;
key_t key;
int msgid;
int reval;
struct msgsbuf{
int mtype;
char mtext[1];
}msg_sbuf;
struct msgmbuf
{
int mtype;
char mtext[10];
}msg_rbuf;
struct msqid_ds msg_ginfo,msg_sinfo;
char* msgpath="/home/wulei/wulei/ipc.c";
key=ftok(msgpath,'a');
printf("key is %x",key);
gflags=IPC_CREAT;
msgid=msgget(key,gflags|00666);
if(msgid==-1)
{
printf("msg create error\n");
msgid=msgget(key,0);
if (-1==msgid)
{
printf("111111111\n");
return;
}
}
reval=msgctl(msgid,IPC_RMID,NULL);//删除消息队列
if(reval==-1)
{
printf("unlink msg queue error\n");
return;
}
}
delete queue
最新推荐文章于 2024-03-30 11:22:04 发布