7.2 POSIX 消息队列
打开、关闭和断开消息队列
#include <fcntl.h>
#include <sys/stat.h>
#include <mqueue.h>
/*
@param name 消息队列标识,一般为以 / 开头的字符串
@param oflag 可取:
- O_CREAT 不存在时创建
- O_EXCL 与 O_CREAT 搭配使用,排它地创建队列
- O_RDONLY 只读打开
- O_WRONLY 只写打开
- O_RDWR 读写打开
- O_NONCLOCK 非阻塞模式打开
@param mode 与 attr 在指定 O_CREAT 创建消息队列时使用
mode 为位掩码指定了新消息队列上的权限,与文件权限一致
@param attr 指定消息队列的特性,一般指定为 NULL 采用默认特性
@return 返回消息队列描述符,失败返回 -1
*/
mqd_t mq_open(const char *name, int oflag, ...
/* mode_t mode, struct mq_attr *attr */);消息队列特性
交换消息
与 System V 消息队列比较
最后更新于