mq_unlink的限制是多少
What is the limit in mq_unlink?
mq_unlink的文档说
搪瓷太龙 名字太长了。
但是这个限制是什么?我以为是NAME_MAX
,但事实并非如此。以下代码将永远运行(我猜只要有内存(。
#include <mqueue.h>
#include <string>
#include <errno.h>
#include <unistd.h>
int main(void)
{
std::string tooLong = "long";
do
{
usleep(10);
tooLong.append("longer");
mq_unlink(tooLong.c_str());
}
while(errno != ENAMETOOLONG);
}
那么极限是什么?此函数何时返回ENAMETOOLONG
?
谢谢,你是对的。
问题是缺少斜杠!
#include <mqueue.h>
#include <string>
#include <errno.h>
#include <unistd.h>
#include <iostream>
#include <limits.h>
int main(void)
{
std::string tooLong = "/long";
do
{
usleep(10);
tooLong.append("longer");
mq_unlink(tooLong.c_str());
}
while(errno != ENAMETOOLONG);
std::cout << tooLong.length() << " " << tooLong << std::endl;
}
这有效,长度为 257,正好高于NAME_MAX。
相关文章:
- 复制列表初始化的隐式转换的等级是多少
- while循环中while循环的时间复杂度是多少
- 如何检查一个c++字符串中有多少相同的字符/数字
- C++有多少类型的循环
- 求出有多少个数字是完美平方,而sqrt()是L,R范围内的素数
- 在条件变量中触发错误信号的频率是多少
- 函数的时间复杂度是多少?
- 必须为 C++20 协程帧保留多少内存?
- 对于四轴飞行器,PID中I控制器的理想值应该是多少
- C++,数组有多少个地址?
- 在C++中使用并行化的预期速度是多少(不是 OpenMp,而是 <thread>)
- 在 Linux 中存储区域设置名称的缓冲区大小应该是多少?
- 在内存不足之前,我可以声明多少个 const 变量?
- 可以读入进程内存的最大块大小是多少?
- 如何在不知道C++中有多少可选参数的情况下在循环中使用va_arg?
- 在二维向量或数组中可以存储的最大元素数是多少?
- 如何创建一个所有行大小不同的 2D 数组,并且用户将指定每行将有多少个元素?
- 计算出有多少客户端可以连接到我正在使用的一些tcp服务器代码
- 如果我不知道每个列表中有多少个数字,我如何将给定数量的数字列表作为输入?
- C++中 std::map 的运行时复杂度是多少?