日期:2014-05-16 浏览次数:20771 次
#include<stdio.h> #include<sys/msg.h> //#include"common.h" int main() { int msgid,ret; struct msqid_ds buf; msgid = msgget(111,0666 | IPC_CREAT); if(msgid >= 0) { printf("Created a message queue.\n"); ret = msgctl(msgid,IPC_STAT,&buf); if(ret == 0) printf("Mode is %o.\n",buf.msg_perm.mode); buf.msg_perm.mode = 0000; ret = msgctl(msgid,IPC_SET,&buf); if(ret == 0) printf("After changed mode is %o.\n",buf.msg_perm.mode); ret = msgctl(msgid,IPC_RMID,NULL); if(ret == 0) printf("Removed a message queue.\n"); } return 0; }