c++ - linux。调用 sys_clone 时的许多文件描述符
问题描述
我使用带有标志 SIGCHLD 的克隆创建 400 个线程 | 克隆_FS | 克隆文件 | 克隆_SIGHAND | 克隆虚拟机
和$ losf | wc -l 运行后显示 600 000 个打开的描述符
我需要做什么?
解决方案
If you're using CLONE_FILES
you probably don't need to do anything.
lsof
shows the sum of file descriptors held by each thread, even though these different threads are sharing a single set of file descriptors on the backend. So if you have a 1000 threads with 100 file descriptors shared, it will appear to be 100,000 file descriptors open if you just check with lsof
.
Check /proc/sys/fs/file-nr
to see the actual number of file descriptors your system has open.
As for whether a tool exists that can determine a list of unique file descriptors and what processes/threads have them open, I'm not sure. I've never needed to do that myself, but it appears to be a problem no one has yet scratched.
推荐阅读
- r - 在ggplot中正确定位多个重要标签
- postgresql - 递归 PostGIS 查询
- tensorflow - 如何在 LSTM 层之间实现跳跃连接结构
- mysql - 使用 GROUP_CONCAT 的 MySql 查询优化
- racket - 这个错误是什么意思?“recon-source:语法没有匹配的子句:(quote-syntax srcloc)”
- python - Robotframework 创建循环查找元素
- winforms - .NET Core 3.1 Windows 窗体设计器错误?
- r - Matlab 到 R 的循环转换
- javascript - Javascript - :Slider On touch 未按预期工作
- javascript - 如何将 html id 更改为变量 Laravel