Linux中每个进程是否有最多打开的文件?

Mal*_*lax 7 linux debian max-file-descriptors

我的问题很简单,实际上已在标题中说明。我的一个应用程序向我抛出关于“打开文件太多”的错误,即使应用程序运行的用户限制高于默认值 1024(lsof -u $USER 报告 3000 个打开的文件)。

因为我无法想象为什么会发生这种情况,我猜每个进程可能有一个最大值。

任何想法都非常感谢!

编辑:一些可能有帮助的值...

root@Debian-60-squeeze-64-minimal ~ # ulimit -n
100000

root@Debian-60-squeeze-64-minimal ~ # tail -n 4 /etc/security/limits.conf 
myapp  soft nofile 100000
myapp  hard nofile 1000000
root soft nofile 100000
root hard nofile 1000000

root@Debian-60-squeeze-64-minimal ~ # lsof -n -u myapp | wc -l
2708
Run Code Online (Sandbox Code Playgroud)

小智 6

您可以找到带有 pid 的进程的限制/proc/<pid>/limits,并且有一个条目Max open files


pfo*_*pfo 5

是的,该ulimit工具会限制打开文件的数量以及许多其他内容,例如堆栈大小、核心转储大小等。