IPC--消息队列 message queue --msgctl函数(删除指定msqid的消息队列)
来源:互联网 发布:苏州网络犯罪举报网站 编辑:程序博客网 时间:2024/06/09 22:58
msgctl 系统调用对 msgqid 标识的消息队列执行 cmd 操作,系统定义了 3 种 cmd 操作: IPC_STAT , IPC_SET , IPC_RMID ,意义分别如下:
- IPC_STAT : 该命令用来获取消息队列对应的 msqid_ds 数据结构,并将其保存到 buf 指定的地址空间。
- IPC_SET : 该命令用来设置消息队列的属性,要设置的属性存储在 buf 中,可设置的属性包括: msg_perm.uid , msg_perm.gid , msg_perm.mode 以及 msg_qbytes .
- IPC_RMID : 从内核中删除 msqid 标识的消息队列。
当cmd是IPC_RMID时,buf指定为NULL,对msqid对应的消息队列进行删除
当cmd是IPC_SET 时,将buf set为 msqid对应的消息队列
当cmd是IPC_STAT ,将msqid对应的消息队列 get到buf
1. 删除消息队列
/* * rmmsq.c * * Created on: 2011-11-14 * Author: snape */#include <stdio.h>#include <wait.h>#include <stdlib.h>#include <sys/msg.h>#include <unistd.h>#include <errno.h>int main(int argc, char **argv) {int msgid;int pid;if ((msgid = msgget(0x1234, 0666)) < 0) {fprintf(stderr, "open message queue %X error\n", 0x1234);exit(1);}if ((pid = fork()) < 0) {perror("fork");exit(1);} else if (pid == 0) {wait(NULL);printf("============================rm msqid %d success\n", msgid);execlp("ipcs", "ipcs", NULL);exit(1);} else {sleep(2);if (msgctl(msgid, IPC_RMID, NULL) < 0) {fprintf(stderr, "rm msqid %d error\n", msgid);exit(1);} else {execlp("ipcs", "ipcs", NULL);}}return 0;}
- IPC--消息队列 message queue --msgctl函数(删除指定msqid的消息队列)
- IPC--消息队列 message queue --msgctl函数(get 指定msqid的消息队列)
- IPC--消息队列 message queue --msgctl 函数(创建 删除 查看 综合运用)
- ipc 消息队列message queue
- IPC 消息队列(message queue)
- IPC--消息队列 message queue(消息队列的创建,信息的发送和接收)
- 进程间通信(IPC):消息队列(Message Queue)
- 消息队列(Message Queue)
- 消息队列(Message Queue)
- 消息队列(Message Queue)
- 消息队列(Message Queue)
- 消息队列(Message Queue)
- 消息队列(message queue)
- 消息队列 (Message Queue)
- 消息队列 ( Message Queue )
- 消息队列(Message Queue)编程
- linux下消息队列(Message queue)
- 什么是消息队列(Message Queue)?
- android系统信息(内存、cpu、sd卡、电量、版本)获取
- 读书笔记6:工厂方法模式
- 11个有用的移动网页开发App和HTML5框架
- 如何通过Linux bash在后台运行任务
- C#TreeView控件如何控制滚动条的位置
- IPC--消息队列 message queue --msgctl函数(删除指定msqid的消息队列)
- iphone的一些小学习要点
- 二分查找法及判断一个数组中是否有两个元素之和为指定值
- 内存溢出的解决办法 Android
- javascript 合并排序算法
- ORACLE客户端乱码--修改Oracle客户端字符集
- 技巧:从切图到网页生成全攻略
- ORACLE RAISE_APPLICATION_ERROR
- Linux内核裁剪的具体步骤