大佬教程收集整理的这篇文章主要介绍了linux – 文件描述符的数量:/ proc / sys / fs / file-nr和/ proc / $pid / fd之间有什么不同?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
cat /proc/sys/fs/file-nr 12750 0 753795
我想知道为什么以下命令中的数字是不同的(假设这一个班轮正在返回正确的值:
for pid in $(lsof | awk'{print $2}’| uniq);找到/ proc / $pid / fd / -type l 2>& 1 | grep -v“不”;完成| wc -l
11069
man proc
:
@H_502_17@/proc/[pid]/task (since Linux 2.6.0-test6) This is a directory that contains one subdirectory for each thread in the process. The name of each subdirectory is the numerical thread ID (@H_502_17@[tid]) of the thread (see 07001). Within each of these subdirectories,there is a set of files with the same names and contents as under the @H_502_17@/proc/[pid] directories. For attributes that are shared by all threads,the contents for each of the files under the @H_502_17@task/[tid] subdirectories will be the same as in the corresponding file in the parent @H_502_17@/proc/[pid] directory (e.g.,in a multithreaded process,all of the @H_502_17@task/[tid]/cwd files will have the same value as the @H_502_17@/proc/[pid]/cwd file in the parent directory,since all of the threads in a process share a working directory). For attributes that are disTinct for each thread,the corresponding files under @H_502_17@task/[tid] may have different values (e.g.,varIoUs fields in each of the @H_502_17@task/[tid]/status files may be different for each thread).
In a multithreaded process,the contents of the @H_502_17@/proc/[pid]/task directory are not available if the main thread has already terminated (typically by calling 07002).
ps -eL | awk 'NR > 1 { print $1,$2 }' | \ while read x; do \ find /proc/${x% *}/task/${x#* }/fd/ -type l; \ done | wc -l
结果是17270.
让我们看看自启动以来分配了多少文件描述符:
cat /proc/sys/fs/file-nr 11616 0 398855
为什么/ proc / [pid] / task / [tid] / fd中的文件描述符数量超过/ proc / sys / fs / file-nr中分配的文件句柄数?我想它们是由分叉的子进程创建的:
以上是大佬教程为你收集整理的linux – 文件描述符的数量:/ proc / sys / fs / file-nr和/ proc / $pid / fd之间有什么不同?全部内容,希望文章能够帮你解决linux – 文件描述符的数量:/ proc / sys / fs / file-nr和/ proc / $pid / fd之间有什么不同?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。