|
- #include<stdio.h>
- #include<sys/types.h>
- #include<sys/ipc.h>
- #include"err_exit.h"
- int main(void)
- {
- key_t key,msgflg;
- int perm_flags,flags;
- int msqid;
- printf("enter the disired key in hex= ");
- scanf("%x",&key);
- printf("\nenter the operation permiddipns in octal=");
- printf("\nenter corresponding number to set the disired flags:\n");
- printf("no flags =0\n");
- printf("IPC_CREAT =1\n");
- printf("IPC_EXCL =2\n");
- printf("IPC_CREAT and IPC_EXCL= 3\n");
- printf("flags=");
- printf("%d",&flags);
- printf("\nkey=0x%x,perm_flags=0%o,flags=0%o\n",key,perm_flags,flags);
- switch (flags){
- case 0:
- msgflg=(perm_flags | 0);
- break;
- case 1:
- msgflg=(perm_flags | 0);
- break;
- case 2:
- msgflg=(perm_flags | 0);
- break;
- case 3:
- msgflg=(perm_flags | 0);
- }
- printf("\nmsgget :calling msgget(% # 1x,% # o)\n",key,msgflg);
- if((msqid=msgget(key,msgflg))==-1)
- err_exit("the msgget failed");
- else{
- printf("the msgget succeeded :msqid= %d\n",msqid);
- exit(0);
- }
- }
复制代码
一个创建消息队列的程序,但我是只能输入1次为什么呢!? |
|