19 February 2013

Get list of file descriptors used by a process in linux

In Linux, you can get a list of all file descriptors used by a running program (process). It is found under path /proc/{pid}/fd example, I've started tomcat and go to: /proc/3613/fd. output of the above directory (on my local machine):
lr-x------ 1 mhewedy mhewedy 64 Feb 19 01:15 0 -> /dev/null
l-wx------ 1 mhewedy mhewedy 64 Feb 19 01:15 1 -> /windows/Work/linuxInstallations/apache-tomcat-7.0.29/logs/catalina.out
l-wx------ 1 mhewedy mhewedy 64 Feb 19 01:15 10 -> /windows/Work/linuxInstallations/apache-tomcat-7.0.29/logs/host-manager.2013-02-19.log
lr-x------ 1 mhewedy mhewedy 64 Feb 19 01:15 11 -> /windows/Work/linuxInstallations/apache-tomcat-7.0.29/lib/annotations-api.jar
lr-x------ 1 mhewedy mhewedy 64 Feb 19 01:15 12 -> /windows/Work/linuxInstallations/apache-tomcat-7.0.29/lib/catalina-ant.jar
.....................................
Notice that the stdin reads from /dev/null, the stdout write to catalina.out file.

No comments: