linux 进程 文件句柄
应用程序在一直使用文件句柄,而不释放文件句柄时,可能导致文件句柄资源耗尽,当文件句柄耗尽自后所用的打开/新建文件函数都会返回错误,open、create、fopen、popen、socket。1、查看系统默认的进程最大文件句柄数(socket也算文件句柄),linux系统默认是1024# ulimit -n10242、查看进程打开的文件句柄step1:查看(
·
应用程序在一直使用文件句柄,而不释放文件句柄时,可能导致文件句柄资源耗尽,当文件句柄
耗尽自后所用的打开/新建文件函数都会返回错误,open、create、fopen、popen、socket。
1、查看系统默认的进程最大文件句柄数(socket也算文件句柄),linux系统默认是1024
# ulimit -n
1024
2、查看进程打开的文件句柄
step1:查看(App)进程号
#ps
PID USER VSZ STAT COMMAND
1 root 1708 S init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [kworker/0:0]
6 root 0 SW [rcu_kthread]
7 root 0 SW< [khelper]
8 root 0 SW [kworker/u:1]
194 root 0 SW [sync_supers]
196 root 0 SW [bdi-default]
198 root 0 SW< [kblockd]
204 root 0 SW< [ata_sff]
215 root 0 SW [khubd]
223 root 0 SW< [cfg80211]
224 root 0 SW [kworker/0:1]
306 root 0 SW< [rpciod]
312 root 0 DW [kswapd0]
362 root 0 SW [fsnotify_mark]
369 root 0 SW< [nfsiod]
380 root 0 SW< [crypto]
405 root 0 SW [scsi_eh_0]
408 root 0 SW [scsi_eh_1]
411 root 0 SW [kworker/u:2]
422 root 0 SW [mtdblock0]
427 root 0 SW [mtdblock1]
432 root 0 SW [mtdblock2]
437 root 0 SW [mtdblock3]
442 root 0 SW [mtdblock4]
445 root 0 SW [romblock0]
448 root 0 SW [romblock1]
451 root 0 SW [romblock2]
454 root 0 SW [romblock3]
457 root 0 SW [romblock4]
965 root 0 SW [flush-8:0]
3954 root 288m S < /dvr/bin/App
5798 root 1708 R ps
#
step2:查看进程占用的文件句柄
#cd /proc/3954
#ls fd -l
lr-x------ 1 root root 64 Jun 30 11:58 0 -> /dev/null
lrwx------ 1 root root 64 Jun 30 11:58 1 -> /dev/console
lr-x------ 1 root root 64 Jun 30 11:58 10 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 11 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 12 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 13 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 14 -> /dev/vi
lr-x------ 1 root root 64 Jun 30 11:58 15 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 16 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 17 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 18 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 19 -> /dev/vi
lrwx------ 1 root root 64 Jun 30 11:58 2 -> /dev/console
lr-x------ 1 root root 64 Jun 30 11:58 20 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 21 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 22 -> /dev/vpss
耗尽自后所用的打开/新建文件函数都会返回错误,open、create、fopen、popen、socket。
1、查看系统默认的进程最大文件句柄数(socket也算文件句柄),linux系统默认是1024
# ulimit -n
1024
2、查看进程打开的文件句柄
step1:查看(App)进程号
#ps
PID USER VSZ STAT COMMAND
1 root 1708 S init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [kworker/0:0]
6 root 0 SW [rcu_kthread]
7 root 0 SW< [khelper]
8 root 0 SW [kworker/u:1]
194 root 0 SW [sync_supers]
196 root 0 SW [bdi-default]
198 root 0 SW< [kblockd]
204 root 0 SW< [ata_sff]
215 root 0 SW [khubd]
223 root 0 SW< [cfg80211]
224 root 0 SW [kworker/0:1]
306 root 0 SW< [rpciod]
312 root 0 DW [kswapd0]
362 root 0 SW [fsnotify_mark]
369 root 0 SW< [nfsiod]
380 root 0 SW< [crypto]
405 root 0 SW [scsi_eh_0]
408 root 0 SW [scsi_eh_1]
411 root 0 SW [kworker/u:2]
422 root 0 SW [mtdblock0]
427 root 0 SW [mtdblock1]
432 root 0 SW [mtdblock2]
437 root 0 SW [mtdblock3]
442 root 0 SW [mtdblock4]
445 root 0 SW [romblock0]
448 root 0 SW [romblock1]
451 root 0 SW [romblock2]
454 root 0 SW [romblock3]
457 root 0 SW [romblock4]
965 root 0 SW [flush-8:0]
3954 root 288m S < /dvr/bin/App
5798 root 1708 R ps
#
step2:查看进程占用的文件句柄
#cd /proc/3954
#ls fd -l
lr-x------ 1 root root 64 Jun 30 11:58 0 -> /dev/null
lrwx------ 1 root root 64 Jun 30 11:58 1 -> /dev/console
lr-x------ 1 root root 64 Jun 30 11:58 10 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 11 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 12 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 13 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 14 -> /dev/vi
lr-x------ 1 root root 64 Jun 30 11:58 15 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 16 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 17 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 18 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 19 -> /dev/vi
lrwx------ 1 root root 64 Jun 30 11:58 2 -> /dev/console
lr-x------ 1 root root 64 Jun 30 11:58 20 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 21 -> /dev/vpss
lr-x------ 1 root root 64 Jun 30 11:58 22 -> /dev/vpss
更多推荐
已为社区贡献3条内容
所有评论(0)