unix学习笔记------msgctl函数的使用
来源:互联网 发布:联通软件研究院 亦庄 编辑:程序博客网 时间:2024/05/21 14:01
// msgctl函数的使用:
#include<>
int main()
{
int msgid;
int ret=0;
//rwx
msgid=msgget(0x1234,0666);
if(msgid==-1)
{
if(errno==ENOENT)
{
printf("我们自己检查。。。消息队列不存在\n");
}
if(errno==EEXIST)
{
printf("我们自己检查。。。消息队列已经存在")
}
perror("msgid err");
return -1;
}
printf("msgid:%d \n",msgid);
struct msqid_ds buf;
memset(&buf,0,sizeof(struct msqid_ds));
ret=msgctl(msgid,IPC_STAT,&buf);
if(ret==-1)
{
perror("error msgctl");
return -1;
}
buf.m
//打印消息队列中的信息
printf("权限信息: %o \n",buf.msg_perm.mode);
printf("创建消息队列");
}
// 下面是修改消息队列的状态
int main()
{
int msgid;
int ret=0;
//rwx
msgid=msgget(0x1234,0666);
if(msgid==-1)
{
if(errno==ENOENT)
{
printf("我们自己检查。。。消息队列不存在\n");
}
if(errno==EEXIST)
{
printf("我们自己检查。。。消息队列已经存在")
}
perror("msgid err");
return -1;
}
printf("msgid:%d \n",msgid);
struct msqid_ds buf;
memset(&buf,0,sizeof(struct msqid_ds));
ret=msgctl(msgid,IPC_STAT,&buf);
if(ret==-1)
{
perror("error msgctl");
return -1;
}
buf.msg_perm.mode=0644;
ret=msgctl(msgid,IPC_SET,&buf);//即把我的buf复制到Linux内核中去。
//如果想要删除消息队列的话,可以:
ret=msgctl(msgid,IPC_RMID,NULL);
//打印消息队列中的信息
printf("权限信息: %o \n",buf.msg_perm.mode);
printf("创建消息队列");
#include<>
int main()
{
int msgid;
int ret=0;
//rwx
msgid=msgget(0x1234,0666);
if(msgid==-1)
{
if(errno==ENOENT)
{
printf("我们自己检查。。。消息队列不存在\n");
}
if(errno==EEXIST)
{
printf("我们自己检查。。。消息队列已经存在")
}
perror("msgid err");
return -1;
}
printf("msgid:%d \n",msgid);
struct msqid_ds buf;
memset(&buf,0,sizeof(struct msqid_ds));
ret=msgctl(msgid,IPC_STAT,&buf);
if(ret==-1)
{
perror("error msgctl");
return -1;
}
buf.m
//打印消息队列中的信息
printf("权限信息: %o \n",buf.msg_perm.mode);
printf("创建消息队列");
}
// 下面是修改消息队列的状态
int main()
{
int msgid;
int ret=0;
//rwx
msgid=msgget(0x1234,0666);
if(msgid==-1)
{
if(errno==ENOENT)
{
printf("我们自己检查。。。消息队列不存在\n");
}
if(errno==EEXIST)
{
printf("我们自己检查。。。消息队列已经存在")
}
perror("msgid err");
return -1;
}
printf("msgid:%d \n",msgid);
struct msqid_ds buf;
memset(&buf,0,sizeof(struct msqid_ds));
ret=msgctl(msgid,IPC_STAT,&buf);
if(ret==-1)
{
perror("error msgctl");
return -1;
}
buf.msg_perm.mode=0644;
ret=msgctl(msgid,IPC_SET,&buf);//即把我的buf复制到Linux内核中去。
//如果想要删除消息队列的话,可以:
ret=msgctl(msgid,IPC_RMID,NULL);
//打印消息队列中的信息
printf("权限信息: %o \n",buf.msg_perm.mode);
printf("创建消息队列");
0 0
- unix学习笔记------msgctl函数的使用
- Unix学习笔记----编程实例-------Link函数的实例使用:
- msgctl()函数
- msgctl函数
- msgctl()函数
- msgctl()函数 .
- msgctl()函数
- Unix学习笔记------Stat函数与chmod函数的配合使用
- 消息队列所用到的函数 msgget() msgsnd() msgrcv() msgctl()
- Unix学习笔记------套接字----服务器端函数
- UNIX环境编程学习笔记------编程实例----域名解析函数的函数原型即getaddrinfo()函数原型
- UNIX环境编程学习笔记------编程实例-----对于 函数 inet_ntop()函数的第四个参数的理解
- linux c学习笔记----消息队列(ftok,msgget,msgsnd,msgrcv,msgctl)
- linux c学习笔记----消息队列(ftok,msgget,msgsnd,msgrcv,msgctl)
- C++学习笔记--虚函数的使用
- 【cocos2dx学习笔记】update函数的使用
- Python学习笔记(2):函数的使用
- 学习oracle函数使用的笔记
- H5新特性-慕课01-新增与删除的标签
- svn入门
- 把Emacs配置成C++和LaTeX环境
- 端口号扫描工具---nmap
- 互联网专家资源分享(一)
- unix学习笔记------msgctl函数的使用
- Chrome Native Messaging技术示例
- 动态规划进阶篇
- 使用Qt开发中国象棋(四):步时控制
- Ubuntu server 15.0.4安装Redis cluster
- UVa 10082 WERTYU
- 视觉SLAM漫淡
- JS 的this、new、apply和call详解
- macvim 不能输入中文问题