IPC--消息队列 message queue --msgctl函数(get 指定msqid的消息队列)
来源:互联网 发布:光束灯编程 编辑:程序博客网 时间:2024/04/29 09:14
2. msgctl(msqid,IPC_STAT,&buf); get消息队列的信息
/* * print_msq.c * * Created on: 2011-11-15 * Author: snape */#include <stdio.h>#include <fcntl.h>#include <i386-linux-gnu/sys/types.h>#include <i386-linux-gnu/sys/msg.h>#include <string.h>#include <errno.h>#include <stdlib.h>void print_msq(int msqid);char * getMode(mode_t, char *);int main(int argc, char **argv) {int msqid;if ((msqid = msgget(0x1234, 0666 | IPC_CREAT)) < 0) {perror("msgget");exit(1);}print_msq(msqid);return 0;}//get 指定msqid的消息队列得信息 并打印void print_msq(int msqid) {struct msqid_ds buf;char s[20];memset(&buf, 0, sizeof(buf));if (msgctl(msqid, IPC_STAT, &buf) < 0) {perror("msgctl IPC_STAT");return;} else {getMode(buf.msg_perm.mode, s);fprintf(stderr, "%10d %10x%10o%10s\n", buf.msg_perm.uid,buf.msg_perm.gid, buf.msg_perm.mode, s);printf("hello %d\n", msqid);}}char * getMode(mode_t mode, char *buf) {if (buf == NULL) {fprintf(stderr, "buf can't be NULL\n");return NULL;}memset(buf, '-', 9);if (mode & S_IRUSR)buf[0] = 'r';if (mode & S_IWUSR)buf[1] = 'w';if (mode & S_IXUSR)buf[2] = 'x';if (mode & S_IRGRP)buf[3] = 'r';if (mode & S_IWGRP)buf[4] = 'w';if (mode & S_IXGRP)buf[5] = 'x';if (mode & S_IROTH)buf[6] = 'r';if (mode & S_IWOTH)buf[7] = 'w';if (mode & S_IXOTH)buf[8] = 'x';buf[9] = 0;return buf;}
- IPC--消息队列 message queue --msgctl函数(get 指定msqid的消息队列)
- IPC--消息队列 message queue --msgctl函数(删除指定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)?
- 我们为什么需要Windows Workflow Foundation?
- SendMessage和PostMessage的区别
- C语言中强制数据类型转换
- LAMP自动化安装脚本
- mysql中文乱码解决
- IPC--消息队列 message queue --msgctl函数(get 指定msqid的消息队列)
- MySQL 数据库同步
- 区域和裁减区域-Window GDI
- [Software]专业个人知识管理笔记软件Wiz
- 如何让listView加入的HeaderView不可点击
- 分享一个超高效的不规则物体碰撞检测的类~~
- JDK、JRE和ubuntu上java环境的设置
- 动态生成校验码
- Flex页面间三种传值方式